Twitter with OAuth class
Twitter is a service for friends, family, and co-workers to communicate and stay connected through the exchange of quick, frequent answers to one simple question: What are you doing?
Grab your copy
Follow development on GitHub
About
PHP Twitter is a (wrapper)class to communicate with the Twitter API with the use of OAuth.
License
Twitter with OAuth is BSD licensed.
Documentation
The class is well documented inline. If you use a decent IDE you'll see that each method is documented with PHPDoc.
Sites that use this class
Do you know a site that uses this class? Use the form below.
Comments
Add your comment
If you have some feedback, a remark or you just want to say something. Go ahead, use the form below.
Before asking support in the comments, check out the example on getting the tokens and the example on getting the users timeline.
Tijs Verkoyen wrote:
18/05/2010
There are still some issues with this class, they are listed below. I will try to fix these issues in the near feature.
- savedSearchesDestroy isn't working correctly
- trendsLocation isn't working correctly
- oAuthAuthenticate isn't working correctly
- accountUpdateProfileImage isn't implemented
- accountUpdateProfileBackgroundImage isn't implemented
- helpTest isn't working correctly
undooo wrote:
19/05/2010
When tested this, the calculateHeader gave error that second parameter is missing?
I cant do 00 so maybe my fault, but it is called without sendond parameter in the code..
Tijs Verkoyen wrote:
19/05/2010
@undooo: which method where you using?
Michael wrote:
19/05/2010
Hi Tijs,
I'm getting an 'Incorrect signature' error. I'm pretty sure I'm using the right information but I could be wrong. I know the customer key and secret are pretty obvious. They're available on the Application details screen. The OAuth Token and OAuth Token Secret (for the setOAuthToken and setOAuthTokenSecret methods) are on the My Access Token screen, right? Or do I need to request the tokens first, as in the first example you have up there?
Thanks for any help,
Michael
Michael wrote:
19/05/2010
Actually, to clarify, I'm getting the error in the statusesMentions() method. I can call statusesUserTimeline() just fine. However, statusesMentions() gives me the 'Incorrect signature' error, with or without a sinceId specified. Odd.
Alex wrote:
20/05/2010
When do you expect to implement the update profile /background image?
Steve B. wrote:
21/05/2010
Tijs,
Thanks for your work on this, especially the OAuth.
Question for you: If a developer has created a twitter client web-based app and the develper ends up having a user who uses his service to send spam/porn links to their twitter account through the web app, would Twitter take note of the subscription api id used for sending the tweets and ban it, or would they simply blame the individual twitter account ?
michael wrote:
24/05/2010
Tija,
Yep, still getting the error. Did some testing on Friday and so far, the following methods all return the same "Invalid signature" error: statusesMentions(), statusesFriendsTimeline(), accountVerifyCredentials(), statusesUpdate('Just a test.'), statusesReweetsOfMe().
These methods do work successfully: statusesUserTimeline(), statusesPublicTimeline(), statusesFriends(), statusesFollowers(), trends(), trendsCurrent(), trendsDaily(), trendsWeekly().
oAuthRequestToken() and oAuthAuthorize() work but since I am redirected to Twitter, then back to my callback URL, I never get to see what token and secret are returned by Twitter, to see if they match what I'm using.
michael wrote:
24/05/2010
Er, sorry for spelling your name wrong, Tijs. Heh.
GHengeveld wrote:
31/05/2010
I'm trying to incorporate this in my framework, but I keep getting the error "This method requires a GET" when I call the statusesUserTimeline() method, which seems to be a limitation on the Twitter side. Any solution for this?
Hank wrote:
01/06/2010
I used the old version of your twitter, but with this one I have no clue how to use it ?
On Twitter I have the consumer key / secret,
But what about the callback url? What should it contain and how does it work? Do you have a example of that ?
GHengeveld wrote:
01/06/2010
@Hank: In the example, the callback URL will simply be the URL of the main script. In practice it's more likely you'll be using a seperate script for the callback, which will store the oauth token secret in the session or database instead of using them directly, and then redirect back to the main script.
Jesse wrote:
04/06/2010
Is there a workaround for when your server doesn't support CURLOPT_FOLLOWLOCATION when in safe_mode or an open_basedir is set?
nibot wrote:
06/06/2010
tijs,
i got the same error's as michael, incorrect signature after callback to my site what is the solution?
steve wrote:
08/06/2010
In case this didn't get through the first time:
I'm getting the incorrect signature, too, but the public timelines is working. Just an fyi, that's all.
Thanks for your work on this.
Steve
Tenk wrote:
10/06/2010
Tijs,
Is there a way that you can catch the "error" when Twitter is to busy (reply from your class) and display a nice message ?
Michael wrote:
11/06/2010
@Tijs,
Heh, you know what, it's working now. For some reason I had the wrong Consumer Key and Secret set in the code. Just point me to the jackass chair, I'll take my seat. Thank you for your help, though.
Pheno wrote:
13/06/2010
undooo is right:
Warning: Missing argument 2 for Twitter::calculateHeader(), called in twitter.php on line 280 and defined in twitter.php on line 230
Haven't tested whether it matters, though.
Pheno wrote:
15/06/2010
Regarding my previous comment... tested it now and it works fine. It's just a warning that can easily be resolved (= null is your friend).
Works great, decent documentation, clear code. Thanks a lot.
fich wrote:
18/06/2010
hi Pheno,,
what line number do you change in twitter.php
did you change like this?
private function calculateHeader(array $parameters, $url=null)
I still got error: Notice (8): Undefined variable: url [APP\vendors\twitter.php, line 234]
Tijs Verkoyen wrote:
20/06/2010
@nibot: did you check your consumerkey and secret key?
@steve: did you check your consumerkey and secret key?
@Tenk: When Twitter is too busy an exception will be thrown, so you should wrap the call in a try-catch statement and handle that.
@michael: I'm relieved it is just that and not my code.
@pheno: will be fixed in next version
@fich: yes
Sandra wrote:
28/06/2010
Tijs after using the method statusesUserTimeline() I got:
Uncaught exception 'TwitterException' with message 'This method requires authentication.'
My code:
$twitter = new Twitter('41Nz....', 'p4Oa...');
$twitter->setOAuthToken('125...);
$twitter->setOAuthTokenSecret('SaD...');
$response = $twitter->statusesUserTimeline();
I got my user tocken information from the screen myappliation/myaccesstoken. Shouldn't it wotk?
can u give me a hand please, I don't know what I'm missing :S
Jim Morrison wrote:
08/07/2010
Tijs, great library thanks!
One quick question; why is the URL in oAuthAuthorize set to /oauth/authorize rather thank /oauth/authenticate?
The way it's set my application _always_ asks for approval, even if the user's logged in to Twitter and has approved the application.
By changing it to /oauth/authenticate Twitter makes a decision based on whether you've allowed the application before and redirects immediately if you have... making the transaction seemless.
Have I misunderstood the process?
Thanks!
Jim
fich wrote:
13/07/2010
hi Tijs,,
in calculateHeader function, there is some code
Authorization: OAuth realm = $url
what does exactly $url refer to?
thx
Mindcrime wrote:
20/07/2010
calculateHeader in doOAuthCall() should have this:
self::SECURE_API_URL .'/oauth/'. $method
Josh wrote:
04/08/2010
userListsIdStatuses seems to disregard the parameters except for $page.
tried with both public and private list.
// example: try to get 50 recent, but only 20 are returned
$sinceId = $maxId = $count = $page = null;
$count = 50;
$tweets = $twitter->userListsIdStatuses('twitterapi', 'team', $sinceId, $maxId, $count, $page);
print_r($tweets);
Josh wrote:
04/08/2010
Resolved the problem with count.
inside userListsIdStatuses around line 1391 find this
if($count != null) $parameters['count'] = (int) $count;
and change to
if($count != null) $parameters['per_page'] = (int) $count;
Gaetan wrote:
10/08/2010
Hi, I have tried your class and it works pretty well,
I just got one problem (plus the warnings):
when I get the statuses from users, characters are not encoded and I got many garbage when it comes to accentuated characters : ça…: L’
i tried htmlentities but it doesn't work, I will try to add it somewhere in your class or did I miss something?
Gaetan wrote:
10/08/2010
I didn't find out where to change it (must be somewhere around line 1210 of twitter.php
$this->doCall('statuses/followers.json', $parameters);
Here is a sample of my code:
$table = $twitter->usersShow($value);
$status = htmlentities($table["status"]["text"]);
I get garbled text when original text was accents
Gaetan wrote:
10/08/2010
Sorry :
got it... it's encoding problem, my browser could not set the languages properly as I received status in different languages...
Jelle wrote:
16/08/2010
What has to be in the callback.php file, anyway?
Is the example given the callback file?
I've tried to run that code, but it gives an error all the time:
Fatal error: Uncaught exception 'TwitterException' with message 'Failed_to_validate_oauth_signature_and_token' in /var/www/subdomain/kipdosync/classes/twitter2.php:2324 Stack trace: #0 /var/www/subdomain/kipdosync/test.php(24): Twitter2->oAuthRequestToken('http://kipdosyn...') #1 {main} thrown in /var/www/subdomain/kipdosync/classes/twitter2.php on line 2324
Right now my callback file just dumps all the post and get variables to a file, but it's never reached.
Tijs Verkoyen wrote:
16/08/2010
Changelog since 2.0.0
- no more fatal if twitter is over capacity
- fix for calculating the header-string (thx to Dextro)
- fix for userListsIdStatuses (thx to Josh)
Owen wrote:
01/09/2010
Hi there,
Similar issue to Sandra above, I have a simple script with based on the sample for displaying user timeline:
require_once 'twitter.php';
// create instance
$twitter = new Twitter('dGA...GW4','fJk...18u');
// set tokens
$twitter->setOAuthToken('1853...6JQ');
$twitter->setOAuthTokenSecret('92k...0jU');
// get users timeline
$response = $twitter->statusesUserTimeline();
// output
var_dump($response);
but all I'm getting is:
{"request":"/1/statuses/user_timeline.json","error":"This method requires authentication."}array(1) { [0]=> int(1) }
I've checked and rechecked my credentials and I'm pretty sure they're correct. Any ideas?
Owen
rostr wrote:
02/09/2010
what should i use for callback url, used the domain which it should return back after authenticate
dont have an idea.
// get a request token
$twitter->oAuthRequestToken('<your-callback-url>');
Mario Nava wrote:
02/09/2010
Could post an example of sending status to twitter?
daniel wrote:
02/09/2010
Hello, anyone knows how to rescue oAuthTokenSecret and oAuthToken for
save a plain text file?
Thanks!
TechRavingMad wrote:
03/09/2010
Is there any chance of getting an out-of-band authentication method included in the class? I loved using this for my desktop app, but it runs via cron without a callback URL so all the oAuth options you have don't seem to work. I tried using some of your calls but I couldn't get it to work. Having an out-of-band option would be great.
Thanks for all the work you put into this.
rostr wrote:
03/09/2010
Hi,
Uncaught exception 'TwitterException' with message 'This method requires a GET.'
sometimes i get this error need some help on this
JennCria WebMaster wrote:
03/09/2010
Hi Tijs,
first of all, I want to thank you for your twitter class, but now I am in trouble... May you please write a very simple example about the use of it?
For example: I have an account called account and a password.
I want to tweet a message, just this. Can you help me?
All the best
billtheblue wrote:
04/09/2010
@TechRavingMad
Try commenting out this line in the doCall() method...
[code] $oauth['oauth_token'] = $this->getOAuthToken();[/code]
This class always tries to use three-legged (in-band) authentication even when the function does not require it... commenting out that header makes it so there isn't a blank AuthToken, so Twitter API doesn't complain about the lack of authentication (you are already authenticated by the consumer key / secret, you just need a token for methods that interact with a consumer's account)
winus wrote:
04/09/2010
Hallo,
Ik krijg de volgende error in mijn live omgeving;
SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Dat is op een Debian Etch installatie.
Op mijn windows develop omgeving werkt het perfect...
Hoe kan dit komen?
curl 7.21.1 (i686-pc-linux-gnu) libcurl/7.21.1 OpenSSL/0.9.8c zlib/1.2.3
The Compass wrote:
07/09/2010
Hi, really great class (the best i ever tested for twitter in fact). However, i have a bug : if i call statusesFriends($ID) right after following somebody via friendShipsCreate($ID,null,null,true), i get a "This method requires a GET." error. This is really strange, since it looks like twitter is remembering the old POST request (for the follow). Is this a bug ?
Sebastian Eggers wrote:
08/09/2010
I used the old version of this script (without OAuth) to post Twitter messages from a php script running with a cronjob.
Is this still possible with the new version? I can make it work when I run it with a browser, but is there a way to work it with a command-line call?
Thanks for your help and for this very useful script.
Sebastian Eggers wrote:
08/09/2010
Thanks a lot Silas, that´s exactly what I needed.
All the time I tried to authenticate somehow after setting Token and Secret Token, that it wouldn´t be needed to explicitly do this simply didn´t occur to me.
Tijs, it would be very helpful to include this in the code example on the documentation page.
Silas Olatayo wrote:
08/09/2010
@Sebastian
You are welcome.
Neamar wrote:
12/09/2010
Hi,
I'm a huge fan of this class : easy to use, compact, and packed with every function you'll ever need.
However, i have an error to report. If you use statusesFriends($ID); once, then follow someone (friendShipsCreate($ID,null,null,true)), and you then try to get his friends (via statusesFriends($ID) again), you get an error from Twitter :This method require a GET.
Strange, since i checked it and you send a GET with this query... why would the second call fail ? Help please ;)
mariotux wrote:
14/09/2010
In doCall method, to work fine It need put this line after last option for curl:
$options[CURLOPT_POST] = false;
Then I can get Timeline:
$twitter = new Twitter('XXXX', 'XXXX);
$twitter->oAuthRequestToken();
$result = $twitter->statusesPublicTimeline();
Tijs wrote:
16/09/2010
Changelog since 2.0.1
- Fixed some documentation
- Added a new method: usersProfileImage
- Fixed trendsLocation
- Added new GEO-methods: geoSearch, geoSimilarPlaces, geoPlaceCreate (not tested because geo-services were disabled.)
- Added legalToS
- Added legalPrivacy
- Fixed helpTest
Valerie wrote:
23/09/2010
Warning: curl_setopt_array() [function.curl-setopt-array]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in
With the update to 2.02 from 1.04
Luiz Felipe wrote:
23/09/2010
Translated by Google Translator
Hello, first let me congratulate you for the simplicity of Twitter class. From what I saw she has a little problem. Next, the method statusesUpdate performs a POST operation and the method as well as other statusesUserTimeline performs a GET operation. If we run before statusesUpdate statusesUserTimeline is registered in CURL POST and GET request does not work.
Only after I added the line $ options [CURLOPT_HTTPHEADER] = $ headers;
this
$ Options [CURLOPT_POST] = $ method == 'POST';
I hope that this information helps.
Mensagem original em português.
Olá, primeiro gostaria de dar os parabéns pela simplicidade da classe Twitter. Pelo que vi ela apresenta um pequeno problema. Seguinte, o método statusesUpdate executa uma operação POST e o método statusesUserTimeline assim como outros executa uma operação GET. Se executarmos statusesUpdate antes de statusesUserTimeline fica registrado na CURL o POST e a requisição GET não funciona.
Apenas adicionei após a linha $options[CURLOPT_HTTPHEADER] = $headers;
isto
$options[CURLOPT_POST] = $method == 'POST';
Espero que está informação ajude a resolver esse pequeno problema.
Indranil wrote:
24/09/2010
Hey,
Thanks for the awesome awesome script man, helped me loads.
I also kept getting the "This method requires a GET.", so I changed the code, added one line, and it all works fine now =>
Add this after line # 427 :
$options[CURLOPT_POST] = 0;
(What happened was that if the first request was POST, the option stayed POST, thus throwing that error.)
dejf wrote:
05/10/2010
Isn't it time to cleanup this of all the spam?
BTW: good work
Krystman wrote:
07/10/2010
I also get this error ;_(
Warning: curl_setopt_array() [function.curl-setopt-array]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /www/htdocs/w008d927/www2/twitter.php on line 446
{"request":"/1/statuses/update.json","error":"Could not authenticate you."}
dipan wrote:
13/10/2010
Hi
I am using twitter.php with version 2.0.2.
I am getting this error
Fatal error: Uncaught exception 'TwitterException' with message 'Failed_to_validate_oauth_signature_and_token' in C:\wamp2\www\itexpert\resources\twitter.php:2373 Stack trace: #0 C:\wamp2\www\itexpert\index.php(13): Twitter->oAuthRequestToken('http://localhos...') #1 {main} thrown in C:\wamp2\www\itexpert\resources\twitter.php on line 2373
I am using below code.
require_once('resources/twitter.php');
//initiate libs
$utils = new Utils;
$twitter = new Twitter('xxx', 'xxx');
// get a request token
$twitter->oAuthRequestToken('http://localhost/itexpert/');
// authorize
if(!isset($_GET['oauth_token'])) $twitter->oAuthAuthorize();
// get tokens
$response = $twitter->oAuthAccessToken($_GET['oauth_token'], $_GET['oauth_verifier']);
// output, you can use the token for setOAuthToken and setOAuthTokenSecret
var_dump($response);
Please help me out.
Thanks
Tijs Verkoyen wrote:
13/10/2010
Changelog since 2.0.2
- tested geo*
- implemented accountUpdateProfileImage
- implemented accountUpdateProfileBackgroundImage
- fixed issue with GET and POST (thx to Luiz Felipe)
- added a way to detect open_basedir (thx to Lee Kindness)
Tijs Verkoyen wrote:
13/10/2010
@Valerie: just remove the line where CURLOPT_FOLLOWLOCATION is set. Or download the new version
@Luiz Felipe: thx mate! fixed the bug.
@Indranil: Should be fixed in current version (2.0.3)
@dejf: done
@Krystman: Should be fixed in current version (2.0.3)
@dipan: can you test with the current version?
Dan wrote:
13/10/2010
Hi, I just updated the client from 2.0.1 to 2.0.3 and I'm having an issue getting user mentions now it seems. When trying to run it specifying "$twitter->statusesMentions($count=3)" as before, I get the following exception:
Fatal error: Uncaught exception 'TwitterException' with message 'Incorrect signature' in /home/sites/digitallifemanagement.co.uk/public_html/manage/libraries/twitter/twitter.php:556 Stack trace: #0 /home/sites/digitallifemanagement.co.uk/public_html/manage/libraries/twitter/twitter.php(1007): Twitter->doCall('statuses/mentio...', Array) #1 /home/sites/digitallifemanagement.co.uk/public_html/manage/twitter_frame.php(25): Twitter->statusesMentions('3') #2 {main} thrown in /home/sites/digitallifemanagement.co.uk/public_html/manage/libraries/twitter/twitter.php on line 556
If I remove the count from it, it works fine.
I really like this class that you've made, have saved me a lot of hassle and work! Thought I would report the above issue in case anyone else has a similar issue?
Dan wrote:
13/10/2010
Oops, didn't mean to include all the site information! My bad, haha
Dan wrote:
13/10/2010
Same issue occurs if I do
$twitter->statusesMentions(NULL,NULL,3);
With the debugger on I get
string(77) "{"error":"Incorrect signature","request":"/1/statuses/mentions.json?count=3"}"
Sorry to keep putting messages up, am just trying to get to the root of the issue :)
Mark wrote:
14/10/2010
Just started using this class. Also getting incorrect signature with call to
$twitter->statusesHomeTimeline
Mark wrote:
14/10/2010
Mentions also has the same "incorrect signature" error. $a=$twitter->statusesMentions($replysince,null,null,null);
However, if I don't provide the first parameter,
$a=$twitter->statusesMentions(null,null,null,null);
it gives me all the statuses (ie no error)
Any ideas why? I read something someplace about parameter order needs to be correct?
Tijs wrote:
25/10/2010
@Dan, @Mark: it seems that some parameters aren't working anymore. I will update the class as soon as possible.
Andreas Fritsch wrote:
31/10/2010
Why publicTimeline need a Authentification? Do you know a short way to use the call without any key?
Martijn de Haan wrote:
04/11/2010
To fix the use of sinceId parameter in statusesMentions change the way $base is generated: it must use the original URL (without the parameters).
in doCall(), at the top (around line 361), add:
$baseUrl = (string) $url;
And around line 436, change the existing piece of code to:
$base = $this->calculateBaseString(self::API_URL .'/'. $baseUrl, $method, $data);
It was a wild guess, but it works. ;o
Scooter wrote:
18/11/2010
Was hoping to move up to the newer OAuth version of this great class, but alas, I keep getting this error:
PHP Fatal error: Uncaught exception 'TwitterException' with message 'Invalid / used nonce' in /var/www/html/app/widgets/twitter/twitter.php:559\nStack trace:\n#0
/var/www/html/app/widgets/twitter/twitter.php(984): Twitter->doCall('statuses/user_t...', Array, true)\n#1 /var/www/html/app/widgets/twitter/api-test.php(21): Twitter->statusesUserTimeline('twitterAPI')\n#2 {main}\n thrown in /var/www/html/app/widgets/twitter/twitter.php on line 559
I get this error no matter what method I call ... even legalTOS(). :(
CODE:
require_once 'twitter.php';
$consumerKey = '09...1A';
$consumerSecret = '4o...so';
// the user (me for this test)
$twitterToken = '58...Fw';
$twitterSecret = 'v7...UI';
// create instance
$twitter = new Twitter($consumerKey, $consumerSecret);
//set Access Token
$twitter->setOAuthToken($twitterToken);
//set Access Token Secret
$twitter->setOAuthTokenSecret($twitterSecret);
$response = $twitter->legalTOS();
echo '<pre>'; print_r($response); echo '</pre>';
Scooter wrote:
18/11/2010
I believe my errors are caused by our server's time being considerably off.
Hastimal Shah wrote:
28/11/2010
Its great library.. Thanks for providing such a great libs.
Peter van der Zee wrote:
29/11/2010
A: there's spam on yer blog :p
B: when I use the current version (.3) I keep getting an Incorrect signature error. When the exact same script uses .2 all is fine. Thought you might want to know this :)
Don't know why.
Damian wrote:
13/12/2010
Hi, I discovered a problem, if there is an error of type Failed_to_validate_oauth_signature_and_token, the problem is resolved, the server time synchronize them with an NTP server.
At line 289: $ parameters ['oauth_timestamp'] = time () 13387; add 13387 to sync with twitter and my server.
Thaha AC wrote:
15/12/2010
Hi
It was working fine till yesterday.
since yesterday Im getting following error
Fatal error: Uncaught exception 'TwitterException' with message 'Incorrect signature' in /data/~/htdocs/main/includes/twitter/twitter.php:530 Stack trace: #0 /data/~/htdocs/main/includes/twitter/twitter.php(852): Twitter->doCall('statuses/mentio...', Array) #1 /data/~/htdocs/main/xml/twitterStats2.php(13): Twitter->statusesMentions() #2 {main} thrown in /data/~/htdocs/main/includes/twitter/twitter.php on line 530
Iam sure the Key and secret is correct
Michael Kang wrote:
15/12/2010
Hi. Same issue as Thaha AC's here. It was working fine until yesterday and suddenly stopped working. Keep getting "incorrect signature" when calling usersShow().
Tijs wrote:
16/12/2010
Fix from Martijn de Haan seems to fix the issue with "incorrect signature". I will look into the issue
Michael Kang wrote:
17/12/2010
Hi One other issue, in 2.0.3 usersLookup wasn't working well. Now I've reverted to 2.0.2, I get the data just fine. You might be interested to look into this API too. Thanks for the wonderful work.
Colin wrote:
17/12/2010
Thanks for the class. Is there any kind of mailing list to subscribe to so we can be notified of any updates or new versions of the class?
Thaha AC wrote:
23/12/2010
Thanks,
Martijn de Haan's fix did the job
great work Tijis
Adam J wrote:
14/01/2011
Is there a better place to find examples on how to simply post a status message with this class?? The old class was much easier.
Colin wrote:
20/01/2011
Here's a quick example of posting a status message. You would obviously need to define the constants first, and change the require line to point to whatever you have named the Twitter class file.
@require CLASSES_ROOT.'/TwitterOAuth.php';
$twitter = new Twitter(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);
$twitter->setOAuthToken(TWITTER_ACCESS_TOKEN);
$twitter->setOAuthTokenSecret(TWITTER_ACCESS_TOKEN_SECRET);
try
{
$twitter->statusesUpdate($status);
}
catch (TwitterException $e)
{
// Do whatever you want here, log the failure etc
}
krike wrote:
23/01/2011
How do I get all the users of a list? I have the following code but I only get a handfull of members from the list, i guess I have to do something with the next_page parameter but I don't know how:
$members = $twitter->userListMembers('cmstutorial', 'web-design-development');
$mem_list = array();
foreach($members as $m):
if(is_array($m)):
foreach($m as $u):
$mem_list[] = '@'.$u['screen_name'];
endforeach;
endif;
endforeach;
Alex wrote:
31/01/2011
I stored the oauth_token en oauth_tokensecret in a database, because I want to post a tweet on another time. The first time it worked, but a second time with the samen token and secret it is giving an error: Invalid / expired Token
What is the correct way to do this? Must I call some function?
Programador PHP freelancer wrote:
05/02/2011
Thank you!!
I will test! Hug
Programador PHP freelancer wrote:
05/02/2011
Thank you!!
I will test! Hug!!!
Alex wrote:
07/02/2011
I solved my previous problem. I now know how to store to correct information in the database. But I came across the function friendshipscreate and that is not working. Does anyone has an example to use this? Or is this function just aint't working.
Wouter Slob wrote:
08/02/2011
I also ran into problems when requesting statusesFriendsTimeline with a count parameter. Twitter returned error Incorrect Signature.
After some digging it turns out the basestring in doCall(...) is calculated to late. It is calculated after there parameters are added to the url, which results in an incorrect basestring.
The solution is simple:
Move the following line up:
// calculate the base string
$base = $this->calculateBaseString(self::API_URL .'/'. $url, $method, $data);
Place it right above the following line:
// based on the method, we should handle the parameters in a different way
if($method == 'POST')
.....
Wouter Slob wrote:
08/02/2011
Damn...could have saved me some time by reading the latest posts :-S. I assumed the newest post where on top...
luisesanz wrote:
13/02/2011
Hi, Itesting this class in EasyPHP. I get the following exception:
"
Fatal error: Uncaught exception 'TwitterException' with message 'Invalid / expired Token' in C:\Program Files\EasyPHP 2.0b1\www\twitter\twitter.php:558 Stack trace: #0 C:\Program Files\EasyPHP 2.0b1\www\twitter\twitter.php(983): Twitter->doCall('statuses/user_t...', Array, true) #1 C:\Program Files\EasyPHP 2.0b1\www\twitter\prueba4.php(24): Twitter->statusesUserTimeline() #2 {main} thrown in C:\Program Files\EasyPHP 2.0b1\www\twitter\twitter.php on line 558
"
I used the version 2.0.3
My code is:
"
<?php
// require
require_once 'twitter.php';
// create instance
$twitter = new Twitter(' ', ' ');
// create instance
$twitter = new Twitter('<your-consumer-key>', '<your-consumer-secret>');
// set tokens
$twitter->setOAuthToken('<your-token>');
$twitter->setOAuthTokenSecret('<your-token-secret>');
// get users timeline
$response = $twitter->statusesUserTimeline();
// output
var_dump($response);
?>
"
The user and pass are good
thank you very much
luisesanz wrote:
13/02/2011
I was very wrong, all bugs fixed. Thank you Tijs and Thank you Silas!
jamaica wrote:
30/03/2011
Some functions convert given cursor value into (int), which does not work when numerized value is too big. i found most cases the next_cursor value is too big to fit into (int), resulting plain wrong pages. find and replace (int) $cursor to (string) $cursor solved the problem. Hope this helps and please update the code! Thanks!
Dan Ives wrote:
14/04/2011
Hey,
I wondered if there was any update on the 'Incorrect signature' issue for the statusesMentions function? Am trying to retrieve them in the following way
$mentions = $twitter->statusesMentions(null,null,2,null);
However, am still getting the same response:
Fatal error: Uncaught exception 'TwitterException' with message 'Incorrect signature' in /[sitePath]/libraries/twitter.php:556 Stack trace: #0 /[sitePath]/libraries/twitter.php(1007): Twitter->doCall('statuses/mentio...', Array) #1 /[sitePath]/index.php(15): Twitter->statusesMentions(NULL, NULL, 2, NULL) #2 {main} thrown in /[sitePath]/libraries/twitter.php on line 556
Has anyone been able to solve this? Have tried the solutions in the previous messages but to no avail...
Any help would be greatly appreciated! Thanks.
Dan
Jelmer wrote:
11/05/2011
Nice class! Tnx for sharing, I like using this one.
Jamie wrote:
25/05/2011
A little tip:
If all this OAuth stuff is a little too much for you to get your head round, and you can survive with basic functionality, it is fairly easy to create a wrapper for mobile.twitter.com using cUrl and some basic scripting.
All thats needed is the authorization token from the login page (in a hidden form element) which can then be posted to the login page along with your username and password..
Once you have logged in, the authorization token becomes valid for tweeting which is again a simple matter of posting the auth token along with your tweet.
Hope this helps somebody :)
clankill3r wrote:
26/05/2011
Does it still work, cause i can't get it to work.
I tried tons of tutorials the last few days and i fail by them with all.
:(
Plz post a link of how to get it working.
Mindcrime wrote:
19/07/2011
Bug in v2.1.2: Line 317
Mindcrime wrote:
19/07/2011
Grrr, a bracket is wrongly placed...
Gurkan Karadere wrote:
19/07/2011
I'm getting the following error each time I update status:
PHP Fatal error: Uncaught exception 'TwitterException' with message 'Invalid response.' in /usr/home/webuser/public_html/twitter.php:515\nStack trace:\n#0 /usr/home/webuser/public_html/twitter.php(1165): Twitter->doCall('statuses/update...', Array, true, 'POST')\n#1 /usr/home/webuser/public_html/twit.php(25): Twitter->statusesUpdate('Post test...')\n#2 {main}\n thrown in /usr/home/webuser/public_html/twitter.php on line 515
Any help would be appreciated very much.
Thank you.
Dave wrote:
27/09/2011
Nice class, but had to rewrite most functions to trap exceptions instead of just breaking out.
What's up with all this spam?
Jazzpr wrote:
08/10/2011
My post just disappeared from the above... what's wrong?
Dave wrote:
20/10/2011
FWIW, I have the 2.1.2 class/code with all the exceptions encapsulated inside of try/catch patterns (and there are a lot).
nickycomm wrote:
10/11/2011
Thank you so much for developing this library. I tried other ones, but yours is the only that I managed to make work.
Could you tell me is there's a way to have Twitter's API automatically shorten an URL in the status update?
many thanks!
Antriksh Goswami wrote:
01/12/2011
We updated the twitter application access to:
Read, Write and Access
And Are using "oauth/authorize" for the user-entering-their-credentials step of OAuth
but when getting direct messages it says:
This application is not allowed to access or delete your direct messages
Any thoughts How to resolve with this issue.
Dave Harris wrote:
21/12/2011
Fantastic work Tijs. I had to make a slight change to the function trends(). It was using the deprecated method, so I updated this and now its working again :)
public function trends()
{
return (array) $this->doCall('/trends/1.json');
}