Given below is the code that will help you retrieve tweets from your Twitter account and display them on the PHPBB page.
$c = curl_init(); $auth_myself = 'pcquest'; $auth_pass='password'; curl_setopt($c, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/.xml?count=5"); curl_setopt($c,CURLOPT_USERPWD,'$auth_myself:$auth_pass'); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); $src = curl_exec($c); curl_close($c);
This is how your tweet looks on the website. You can even change the position where tweets are displayed.
You need to whitelist the IP addresses of all websites where you want to insert your tweets.
$tweets = new SimpleXMLElement($src); echo $tweets->status[0]->text;
?>
We have used cURL for getting tweets. It allows you to communicate with the server over HTTP or HTTPS. cURL also supports FTP, Gopher, Telnet and LDAP protocols. In the above code, we have initialized cURL and provided authentication details. Next, we specify the URL from where tweets can be retrieved along with the Twitter ID. As we want to retrieve tweets in XML format, using simpleXML we will convert XML into an object that can be processed easily.
Now for integrating it with a PHPBB-based forum, open up the template folder > sub_silver and open the overall_header.tpl file in edit mode. In this, find the following line of code and paste it above the code given in the previous para.
TD background=homepage_files/redtile.gif> src="homepage_files/redcorner6.gif" width=15 border=0>
Note that this code might change depending upon which version of PHPBB you are using, and modifications that you have done. Now, open your PHPBB-based forum and you should be able to see all the tweets.
Get most out of your technology infrastructure investments with Dell
About CIOL | Media Kit | Site Map | Contact Us | Help | Write to us | Jobs@CyberMedia | Privacy Policy
Copyright © CyberMedia India Online Ltd. All rights reserved. Usage of content from web site is subject to Terms and Conditions.