Code Samples
Check to see if Twitter is available
$t = new twitter();
$t->username='myuser';
$t->password='mypass';
echo'<pre>';
print_r( $t->ratelimit() );
echo'</pre>';
Returns
stdClass Object
(
[remaining_hits] => 30
)Get the Public Timeline
$t = new twitter();
$t->username='myuser';
$t->password='mypass';
$t->type='xml';
echo'<pre>';
print_r( $t->publicTimeline() );
echo'</pre>';
Returns (shortened for brevity)
stdClass Object
(
[0] => SimpleXMLElement Object
(
[created_at] => Thu May 29 05:24:38 +0000 2008
[id] => 822268611
[text] => GeoTwittering. http://geotwitter.net/l.aspx?g=78
[source] => GeoTwitter.Net
[truncated] => false
[in_reply_to_status_id] => SimpleXMLElement Object
(
)
[in_reply_to_user_id] => SimpleXMLElement Object
(
)
[favorited] => false
[user] => SimpleXMLElement Object
(
[id] => 736393
[name] => Derik Olsson
[screen_name] => derik
[location] => Flower Mound, Texas
[description] => Entrepreneur in the video & web fields.
[profile_image_url] => http://s3.amazonaws.com/twitter_production/profile_images/53445703/hb_sm_normal.jpg
[url] => http://derikolsson.com
[protected] => false
[followers_count] => 12
)
)
[1] => SimpleXMLElement Object
(
[created_at] => Thu May 29 05:24:54 +0000 2008
[id] => 822268609
[text] => @miki7500 まだ食べ終わってなかったのか
[source] => web
[truncated] => false
[in_reply_to_status_id] => 822268441
[in_reply_to_user_id] => 6098852
[favorited] => false
[user] => SimpleXMLElement Object
(
[id] => 12902532
[name] => ALeE/ありーくっく
[screen_name] => ALeE78
[location] => Japan,hyogo
[description] => ♂。えいりと呼ぶ人もいます。格ゲー部、メガネ美人部、diablo部、モンハン部。モンハン日記→http://monsterhunter.g.hatena.ne.jp/alee/
[profile_image_url] => http://s3.amazonaws.com/twitter_production/profile_images/54304388/cook_normal.jpg
[url] => http://iddy.jp/profile/alee78/
[protected] => false
[followers_count] => 464
)
)
Not having any luck with either the updateColors or updateBackground methods. Passing an array with the proper data for updateColors and a binary image for updateBackground. Are these methods functioning properly or am I missing something?
Could you provide examples of them in action please? I would really appreciate it.
thanks ver y good work
cool i hope it work
it did work but during update it will not work
How to find out the username and password is correct?
@vinodkumark87 I think it is not hard to check Twitter account. Following are 2 ways and I think they work well:
//1. Get public time line with your username and password: $oTwit = new twitter(); $oTwit->username = 'folext'; $oTwit->password = 'folext'; $oTwit->type = 'xml'; $aPublicUpdates = $oTwit->publicTimeline(); if(count($aPublicUpdates) > 0){
}else{ } /////////////// //2. Send a test update and remove it immediately.Where do I put this file if I want it to work on a wordpress page?
If you are trying to get tweets using the since_id parameter, bear in mind that your results may not be correct. It seems that when PHP encounters an INT that is larger than PHP_INT_MAX, it will convert it to a float. That SHOULD be OK, but I found that, at least with PHP 5.2.9, when an INT larger than PHP_INT_MAX was wrapped to a negative number. A simple fix was to go into the method that I was calling and change the variable type cast from INT to FLOAT.
For example, on my system, the following code: echo "My big number is: 3523044696\n"; echo "On my system PHP 5.2.9, PHP_INT_MAX size is " . PHP_INT_MAX . "\n"; $x = (int)3523044696; echo "Stuffed into an integer, my number becomes $x\n";
yields:
My big number is: 3523044696 On my system PHP 5.2.9, PHP_INT_MAX size is 2147483647 Stuffed into an integer, my number becomes -771922600
Someone who try the first example will find this code not working. Try second one. In first one. there is an error in function ratelimit(). Change from this: return $this->objectify( $out ); To: return $this->objectify( $this->process($out) );
The first and second examples are not working....I tried step 1 of tuvinhvietnam and it works...What can be the problem?
this stuff seems to be deprecated, twitter doesn't support basic auth anymore