# username field public $username; # password field public $password; # maximum no. of values public $maxItems; # path value public $path; # timezone value public $timezone; public $configs = array(); # template file name public $template;
Next comes the constructor method. it defines our template variable. we will replace the template values.
public function __construct() { $this->template = "
we set the necessary values with this method like username, password, maxItem shows the maximum no. of items to be displayed, and timezone will be your timezone.
public function setInfo($username, $password, $maxItems = '5', $timezone = '+6') { $this->username = $username; $this->password = $password; $this->timezone = $timezone; $this->maxItems = $maxItems; $this->config(); }
We set necessary configuraion Information with these function.
public function config() { $this->configs['template'] = $this->template; $this->configs['maxitems'] = $this->maxItems; }The following function shows all your tweets. you can apply css style within the html elements. the cut and resume functions process tweeter responses.
public function easyfeeder() { $content=$this->twitterXml('http://twitter.com/statuses/user_timeline.xml'); $items=explode("",$content); array_shift($items); $retstr=" "; return $retstr; }Latest News
"; foreach($items as $cnt=>$item) { if($this->configs['maxitems']>0 and $cnt+1>$this->configs['maxitems']) break; $created_at=$this->cut("
"," ",$item); $text=$this->cut(""," ",$item); $itemid=$this->cut(""," ",$item); $screenname=$this->cut(""," ",$item); $created_day = substr($created_at, 0, 3); $created_monthday = substr($created_at, 4, 6); $created_timehour = substr($created_at, 11, 2); $created_timehour = $created_timehour + $this->timezone; $created_timeminutes = substr($created_at, 14, 2); $created_year = substr($created_at, 26, 4); if ($created_timehour == 12) { $ampm = "pm"; } else if (($created_timehour > 12) AND ($created_timehour < 24)) { $ampm = "pm"; $created_timehour = $created_timehour - 12; } else if ($created_timehour == 24) { $ampm = "am"; $created_timehour = 12; } else { $ampm = "am"; } $created_at = $created_day . ", " . $created_monthday . ", " . $created_year . " - " . $created_timehour . ":" . $created_timeminutes . $ampm; $itemlink = "http://twitter.com/" . $screenname . "/statuses/" . $itemid; $tpl=$this->configs['template']; $tpl=str_replace("{created_at}",$created_at,$tpl); $tpl=str_replace("{text}",$text,$tpl); $tpl=str_replace("{itemlink}",$itemlink,$tpl); $retstr.=$tpl; } $retstr.="
Following is the cut and resume methods that we used in the above method.
public function cut($start,$end,$word) { $word=substr($word,strpos($word,$start)+strlen($start)); $word=substr($word,0,strpos($word,$end)); return $word; } public function resume($text,$limit=7) { $words=@explode(" ",$text); $words=@array_splice($words,0,$limit); $retstr=@implode(" ",$words); return $retstr."... "; }
The following method will show all you tweeter followers.
public function twitterFollowers() { $this->template = "
Latest News
- "; foreach($items as $cnt=>$item) { if($this->configs['maxitems']>0 and $cnt+1>$this->configs['maxitems']) break; $created_at=$this->cut("
This method will show all your tweeter friends.
public function twitterFriends() { $this->template = "
Latest News
- "; foreach($items as $cnt=>$item) { if($this->configs['maxitems']>0 and $cnt+1>$this->configs['maxitems']) break; $created_at=$this->cut("
let's see how we have connected with tweeter. we used curl to connect with tweeter. the following method done the trick for us.
function twitterXml($url) { $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, "$url"); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_handle, CURLOPT_USERPWD, "$this->username:$this->password"); $buffer = curl_exec($curl_handle); curl_close($curl_handle); return $buffer; }
Links:
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide
List of my works:
Technical Support:
If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.
Wordpress Plugins:
If you still face the technical problem, please get support of our highly skilled technical team: garazlab.com.
Wordpress Plugins:
- Real-Time Health Data from Every Where:WP plugin to display real-time health data & increase sale by promoting user specific products according to health information: garazlab.com.
- Woocommerce Stock Notification Builder:Sends desktop, mobile & email notifications with full customization.Build your own product notification system with it: garazlab.com.
Opencart Extensions:
- Product Based Quantity Wise Shipping: Find it here.
- OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
- Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
- Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
- Custom Field Product - add unlimited custom fields to the product form: Find it here.
- Formcaptcha - add captcha on the register page: Find it here.
4 comments:
Hi,
Do you plan on updating the code to use oauth?
No funciona
I think this tutorial is incomplete
TechNew.In
All in one tech website !
http://www.technew.in/
:)
Post a Comment