Twitter 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?

On August 16, 2010 the @twitterapi team will be shutting off basic authentication on the Twitter API. All applications, by this date, need to switch to using OAuth. Read more

I wrote a new (wrapper)class that uses OAuth for authentication, so grab your copy.

Grab your copy

Download Twitter (1.0.5)

Follow development on GitHub

Follow Twitter

About

PHP Twitter is a (wrapper)class to communicate with the Twitter API.

License

Twitter 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.

More documentation

Sites that use this class

Do you know a site that uses this class? Use the form below.

Comments

Paul Matthews

Paul Matthews wrote:
31/07/2009

Hi

Think there may be a problem in the Twitter wrapper with using (int) to cast the $sinceId values, because the Twitter IDs are now past the maximum int size of 2 billion or so.

E.g. I was using getReplies, and think I have fixed the problem by casting the sinceId to a float instead of an int on line 612

Love the class BTW!

Paul

Tried to post this on your twitter API page, but got an error "something went wrong" !!

Tijs Verkoyen

Tijs Verkoyen wrote:
31/07/2009

Fixed the problems with the int. sinceIds are treated as a string from now on.

Schanie

Schanie wrote:
01/08/2009

Is there a php plugin or a php code to use a twitter search box on a blog or a web site.

Tijs Verkoyen

Tijs Verkoyen wrote:
01/08/2009

I think the API-methods for search are moved into the Twitter API, I'll try to include those methods into the next release of this class.

TheLanceLife

TheLanceLife wrote:
01/08/2009

Thank you for suggesting our simple tutorial :)

Would be interesting to write another one with search functionalities since we did some experiment with search using another simple php lib but would be great to have everything packed together.

If you have any beta to test or review let us know and most of all keep up the great work!

Thank you

Howie

Howie wrote:
01/08/2009

Any plans to add oAuth support?

Tijs Verkoyen

Tijs Verkoyen wrote:
02/08/2009

Changelog since 1.0.3
- rewrote some comments
- fixed some PHPDoc
- it seems Twitter removed the $since-parameter, so I removed it from getFriendsTimeline, getUserTimeline, getDirectMessages, getSentDirectMessages, ...
- implemented maxId into getFriendsTimeline
- renamed getReplies to getMentions to reflect the Twitter API
- added $count for getDirectMessages, getSentDirectMessages, ...
- added getFriendship which shows more details about a friendship
- added getFriendIds and getFollowerIds which return only the ids instead of a user-array
- added existsBlock which test if a block exists
- added getBlocked, which returns an array of blocked user-arrays
- added getBlockedIds, which returns an array of blocked ids

REMARK: the class isn't backwards compatible. See the changelog if the methods you're using are changed.

Valerie

Valerie wrote:
03/08/2009

Hi,

Unfortunately your script has the following problem when using it on a shared host:

Warning: curl_setopt_array() [function.curl-setopt-array]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /location on line 185
/direct_messages/sent.xml Could not authenticate you.
Fatal error: Uncaught exception 'TwitterException' with message 'Unauthorized' in /location/twitter.php:225 Stack trace: #0 /location/twitter.php(864): Twitter->doCall('direct_messages...', Array, true, false) #1 /location/test.php(9): Twitter->getSentDirectMessages() #2 {main} thrown in /location/twitter.php on line 225

Tijs Verkoyen

Tijs Verkoyen wrote:
03/08/2009

Valerie, this has nothing to do with shared-hosting-setups. The warning is triggered because you're working with safe-mode on.
What you can try: comment line 154 (the line that sets the CURLOPT_FOLLOWLOCATION-option).

Hope this works

Valerie

Valerie wrote:
04/08/2009

Hi,

Thanks for you reaction.

It works without line 154, but it seems proper to add this line.

Safe mod was already switched off and open_basedir has been set on my home dir at shared hosting. Still giving the problem with line 154.

Alex

Alex wrote:
07/08/2009

Hi,

I'm use your script.

But I got this error one day ago:

Fatal error: Uncaught exception 'TwitterException' with message 'Operation timed out after 120 seconds with 0 bytes received' in /home/wire/public_html/include_new/twitter.php:213 Stack trace: #0 /home/wire/public_html/include_new/twitter.php(583):

I have increased the time in twice (from 60 to 120).
but it is not help me.

Could you help me with the problem?

Thanks,
Alex

Tijs Verkoyen

Tijs Verkoyen wrote:
07/08/2009

Alex,
The error means the connection to the Twitter API timed out. Nothing I can do about that.

Vanleurth

Vanleurth wrote:
09/08/2009

I'm trying to use your code to change twitter background but I keep getting a "Not Implemented" error.

Is this documented somewhere? I looked through the internet and could not find anything. Any links or answers is appreciated.

Thank you,

David Jones

David Jones wrote:
13/08/2009

I see your Twitter class includes "getMentionsReplies" that retrieves mentions of "@username".

I would like to do something similar and retrieve mentions of a particular word like "#special".

Can you tell me how to do that in PHP using your Twitter class?

thanks in advance, ...

Kamlesh Patidar

Kamlesh Patidar wrote:
14/08/2009

Hi Tijs Verkoyen ,

i got foll0wing error, i am using your API..

Fatal error: Uncaught exception 'TwitterException' with message 'couldn't connect to host' in D:\kamlesh.patidar\project\php\twitter\twitter.php:229 Stack trace: #0 path_to_project_php\twitter\twitter.php(481): Twitter->doCall('statuses/friend...', Array, true, false) #1 \path_to_project_php\twitter\twitter\SendTwitter.php(13): Twitter->getFriendsTimeline() #2 {main} thrown in \path_to_project_php\twitter\twitter.php on line 229

What i can do?
Kamlesh

Devis

Devis wrote:
26/08/2009

Hi, great class, I use it to post phpbb topics. Sometimes I get a Timeout Exception on Curl, even if the timeout is set 60 secs, the timeout occurs after few seconds. Any I can live with it.
Thanks!

Devis

Devis wrote:
26/08/2009

Hi, great class, I use it to post phpbb topics. Sometimes I get a Timeout Exception on Curl, even if the timeout is set 60 secs, the timeout occurs after few seconds. Any I can live with it.
Thanks!

Tijs Verkoyen

Tijs Verkoyen wrote:
27/08/2009

@Devis: Can't do anything about it. A timeout means the connection to Twitter can't be established. So it means Twitter is down or the connection is interupted.

Amir Syafrudin

Amir Syafrudin wrote:
28/08/2009

Sorry for the monologue. The problem was indeed because I'm sitting behind a proxy. I simply set the appropriate options in the doCall functions and I'm set to go.

Thanks.

sp_

sp_ wrote:
02/09/2009

Thanks, your class is the first out of the four php-twitter classes I've found so far.

Alexander Fleites

Alexander Fleites wrote:
02/09/2009

I can't download any class because
all links are broken.....

Mmmmmmmmmmmmmm.

Tijs

Tijs wrote:
02/09/2009

@Alexander Links are working here. Could you point the page with broken links?

jaris

jaris wrote:
07/09/2009

Thanks for the script. How to get the user profile image?
best regards

Chriske

Chriske wrote:
16/09/2009

Dag Tijs, ik wil de classe installeren op mijn site. Staat ergens beschreven wat je juist moet aanvullen in het bestand twitter.php

Thx

PrintSpeed

PrintSpeed wrote:
19/09/2009

Hi, this script looks great. I think i will use it at my website.
Thank you.

Emmanuel

Emmanuel wrote:
30/09/2009

Hello,

There is a bug into line 171, when i have one text with a lot of words with accents like

"olá está é uma mensagem ação ações"

And, the update status doesnt work very well, removing parts of the text.

I suggest update your script into line 171 to:

foreach($aParameters as $key => $value) $var .= '

CNSKnight

CNSKnight wrote:
02/10/2009

lol - thought you had a spam-buster class too! nuh?!
(nntr)

Joel

Joel wrote:
02/10/2009

Hi, I'd love to have some sort of 'caching' system with this too. If you have a website that gets hit a ton, it would be great to see if you can just pull the cached version, or go get the new statuses.

Tijs

Tijs wrote:
02/10/2009

@jaris: use getUser
@Chriske: you don't have to fill in anything in the class itself. See documentation for the usage.
@CNSKnight: indeed, but the wrapper class doesn't block the spam, it communicates with Akismet. So blame Akismet.
@Joel: you should build the caching yourself. I think it is bad practice to get the data each hit. You should a scheduled task (aka cronjob) to get the data.

Rafael Vale

Rafael Vale wrote:
09/10/2009

Hi there. Thanks for the nice class!

I just can't understand how to display the 'time' of the message. i dunno what's this id in 'created_at'... Can you help me?

Christoph

Christoph wrote:
15/10/2009

Hi Tijs,

thank you for you nice PHP Twitter class and the very very good documentation.

I tried to check the previous comments to see if someone had the same problem like me, but I have not found a similar problem.

If I try to use the follow()-function (calling $twitter->follow("xxxx") )with the follower-id as a string I alway get the error:

Fatal error: Uncaught exception 'TwitterException' with message 'There was a problem following the specified user.' in [...]/twitter.php:200 Stack trace: #0 [...]/twitter.php(1550): Twitter->doCall('notifications/f...', Array, true) #1 [...](71): Twitter->follow(XXXXXXXX) #2 {main} thrown in [...]twitter.php on line 200

(I replaced the filepath by [...] to keep the post short and replaced the id by X.)

Is it a problem of your class or is it my mistake?

Thank you for your help.
Christoph

Ulysses

Ulysses wrote:
16/10/2009

Hi Tijs, First of all, thank you for the great class. This is one of the easiest Twitter class I've work with. I've tried several PHP Twitter classes. I settled with yours. I've implemented your class on my site with the ability to show user, friends and public messages. I can also update statuses, (un)favorite, (un)follow, etc. It works great. Occasionally, I get an error message that Twitter is busy or I reached the 150 per hour limit :). How do I suppress the error messages? I want to show a user-friendly error message instead. Thanks!

Ulysses

Ulysses wrote:
17/10/2009

Tijs, Thanks for pointing me in the right direction. I learned something new today with regards to PHP exception handling. The concept is simple enough though. Just try, throw and catch. Thanks so much!

Henry Dawson

Henry Dawson wrote:
21/10/2009

Great class, just noticed a typo in the function name. verifyCrendentials should be verifyCredentials.

developar

developar wrote:
22/10/2009

Thanks, I am using this class in many projects.

Just I have one question:
I saw in TODO that you are planning to implement OAuth into the class, so when you are planning to do it?

Thanks again

bill

bill wrote:
24/10/2009

Hi,

when only writing this:
$twi_user = new Twitter("user","pass");
$user_text = "the above auth info is fake";
$twi_user->updateStatus($user_text);

I get the following:
Warning: curl_setopt_array() [function.curl-setopt-array]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/.../twitter.php on line 185
/statuses/update.xml Could not authenticate you.
Fatal error: Uncaught exception 'TwitterException' with message 'Unauthorized' in /home/.../twitter.php:225 Stack trace: #0 /home/.../twitter.php(646): Twitter->doCall('statuses/update...', Array, true) #1 /home/.../twitterauth.php(10): Twitter->updateStatus('the above auth info is fake') #2 {main} thrown in /home/.../twitter.php on line 225

Thanks for any help with this!

Tijs

Tijs wrote:
24/10/2009

@bill: I think the warning says it all. Disable safe_mode.

Manoj

Manoj wrote:
11/11/2009

Hi somehow i get this message:

Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/.../.../.../twitter.php on line 52

maybe somebody could helP

Joe

Joe wrote:
15/11/2009

Hi, I'm trying to test the twitter bot and I created test file called twitter-11.php contain this :
<?php
require_once 'TwitterBot.class.php';
$bot = new TwitterBot('yayayaya', '123456');
$bot->searchAndRetweet('test', 'RT @%s: %s', true);
?>

This is the error I've got
Fatal error: Call to private method Twitter::getUsername() from context 'TwitterBot' in /home/gfffg/public_html/twitter/gghhgf/TwitterBot.class.php on line 71

Any ideas?


=======================
Can someone please delete those spam comments!!!!!

Matt Squirrell

Matt Squirrell wrote:
23/11/2009

Hello there. I am using a version of PHP (5.04) that doesn't support curl_setopt_array. I replaced line 185 with the following:

foreach ($options as $k=>$v) {
curl_setopt($curl, $k, $v);
}

and all was fine.

Henry Pena

Henry Pena wrote:
10/12/2009

Hello,

Do you know when you'll get around to updating the class to include the lists apis?

Thank you!

Best Regards,

~Henry~

Francis David

Francis David wrote:
10/12/2009

I have problems with accents when i send a status update.
if i send: á123 é123 í123 is posted in twiter á3 é3 í3.

anyone can help me?

Thanks!

Francis David

Francis David wrote:
10/12/2009

Now it´s working...

change the line 171
urlencode(utf8_encode($value));

Jelle De Loecker

Jelle De Loecker wrote:
13/12/2009

Hi,

I'm using your php class for a Facebook twitter-syncing app.

I have a strange experience with getFriendsTimeline():

$timeline = ($twitter->getFriendsTimeline(null,null, 200, 1));

As you can see I requested 200 tweets, but it only gives me about 187 tweets. When I ask for 180 tweets it only gives me about 160 tweets.

Do you know what could be the cause of this?

Thanks!

Francis David

Francis David wrote:
15/12/2009

I´d like to know if is posible to use reTwit in this class.

If is posible, how can i use?

Thank´s!

Andre

Andre wrote:
22/12/2009

Hi there. First things first: thanks for this class. Appreciate your work.

Now the problem :) I got a local xampp installation and everything works fine. In an online shared hosting environment (same curl lib, nearly same php version) I got the following error: " /statuses/user_timeline.xml This method requires authentication." on calling curl_exec($curl) in doCall(...) -> I use the getUserTimeline() method. Same code, same twitter account. Any idea?

TIA Andre

Andre

Andre wrote:
22/12/2009

Small addition: I tested my example on two other shared hosters - works perfectly. Don't know what's wrong with the first one.

 Balu

Balu wrote:
05/01/2010

Hi Tijs,

do you know a solution to check, if a twitter username/password combination exists or check if it is valid?

Is there a hidden possibility in your class to do so, maybe with a return bool.

Greetings from Germany

Tijs

Tijs wrote:
10/01/2010

@Balu:
There isn't a method to test that, but you could create a new Twitter-instance and call the verifyCredentials-method.

// init vars
$username = '<username-to-check>';
$password = '<pass-to-check>';

// create instance
$instance = new Twitter($username, $password);

$isValidCombination = $instance->verifyCredentials();

Tijs

Tijs wrote:
10/01/2010

Changelog since 1.0.4
- renamed verifyCrendentials to verifyCredentials (typo)

Ozzypig

Ozzypig wrote:
14/01/2010

Wow, nice API! It musta taken a while to do. I'll be installing this into my site so that users can Tweet what they are doing.

Mindcrime

Mindcrime wrote:
14/01/2010

2 small bugs in 1.0.5:

getFriends(): $cursor should be $page

Also add in doCall before:
$options[CURLOPT_FOLLOWLOCATION] = true;
the following:
// CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set
$open_basedir = ini_get('open_basedir');
$safe_mode = ini_get('safe_mode');
if (empty($open_basedir)

Mindcrime

Mindcrime wrote:
14/01/2010

invalid

Mindcrime

Mindcrime wrote:
14/01/2010

argh:

ampersand ampersand empty($safe_mode))

Mindcrime

Mindcrime wrote:
14/01/2010

I also remove all utf8_decode() in the class, the class should keep UTF-8...

Adam

Adam wrote:
26/01/2010

Hi everyone . i came up with the retweet function :)


/**
* Retweets the supplied status id
*
* @return array
* @param int[optional] $id
*/
public function retweetStatus($id)
{
// redefine
$id = (string) $id;

// build url
$url = 'statuses/retweet/'. urlencode($id) .'.xml';

// build parameters
$aParameters = array();
$aParameters['id'] = $id;

// do the call
$response = $this->doCall($url, $aParameters, true);

// convert into xml-object
$xml = @simplexml_load_string($response);

// validate
if($xml == false) throw new TwitterException('invalid body');

// return
return (array) $this->statusXMLToArray($xml);
}

Daz

Daz wrote:
01/02/2010

Hi Tijs,

Great API. I installed and it works great for me :)

Quick question. I tried to get the setUserAgent method to work. Eg...

$t = new Twitter($username, $password);
$t->setUserAgent('someUserAgentName');

However, whenever I send tweets out it appears as:
"Sent from API"

I would ideally love it to say, "Sent from someUserAgent" or something similar with API in the text.

Any help you be much appreciated.

1mard

1mard wrote:
02/02/2010

hi
tanx for class.
I have a problem same Daz.
I setUserAgent but whenever I send tweets out it appears as:
"Sent from API"

1mard

1mard wrote:
04/02/2010

Hi Tijs
Have any solution my problems?I had already asked:
I setUserAgent but whenever I send tweets out it appears as:
"Sent from API"

David Mojdehi

David Mojdehi wrote:
11/02/2010

Thanks for this class, it worked perfectly for me.

I added some simple geocoding support to your class. Simply insert the following code:


/**
* The latitude

Orçun

Orçun wrote:
11/02/2010

Tijs, great work.
I had problems with Turkish characters. I couldn't get "ı, ş, ç" and so on. Then I changed the line 371, removed "utf8_decode".
Now it works fine...
fyi...
Thanks...

Ted

Ted wrote:
26/02/2010

Great class! I'm trying to use the getFriendsTimeLine with a count of 100 tweets, as such:

$tweets = $twitter->getFriendsTimeline($count=100);

...but I only ever get back 20 tweets. Any ideas as to why?

djerba

djerba wrote:
07/03/2010

I found you through Blue Print YDN Package :)

Thank you for this helpful class !

alex

alex wrote:
19/03/2010

Hi, i modified your php class so I could access user information after using Twitter::verifyCredentials().

I added a variable:

public $user;

and changed the following code in verifyCredentials().

// content was found
if($response != '') {
$this->user=simplexml_load_string($response);
return true;
}

This will allow a user lo log into twitter and then retrieve some of his info like the screen_name ($twitter->user->screen_name)

Steve B.

Steve B. wrote:
24/03/2010

Tijs, I was wondering if you know the reason for the http error code of 413 when I attempt to make a updateStatus call.

I check the $Header var (the httpcode key of $Header) in requestToTwitter() function and I get this error whenever I attempt to run my php script on my hostgator live server.

However,when running on my local windows machine's php server, I post to twitter fine.
Thanks
Steve

Steve B.

Steve B. wrote:
24/03/2010

Hi Tijs,
I'm just trying to determine if I have a really old version of your twitter clawi
I got my version from PHP Class web site and I think it was named originally my_twitter.php

Have you since renamed requestToTwitter function to doCall or am I talking about two different programmers here :) ?

Steve

Tijs Verkoyen

Tijs Verkoyen wrote:
25/03/2010

@Steve: I never renamed the class.

Steve

Steve wrote:
30/03/2010

Nevermind, Tijs. It was someone else who wrote that.
Great job on the class and thanks

Michael

Michael wrote:
31/03/2010

Great job on this class. Comprehensive, yet easy to use. Thanks for making it available to us.

Tim

Tim wrote:
07/04/2010

Hi I'm using this code:
<?php
include "twitter.php";
$twit = new Twitter("username","password");
$twit->updateStatus("Testing");
?>
but it is giving me error:
/statuses/update.xml Could not authenticate you.

Any suggestions please?

Omar

Omar wrote:
08/04/2010

How does the password is sent? what im trying to say is what kind of encryption is used?
Does Twitter understand a pass sent by md5 for example?

TuxX

TuxX wrote:
09/04/2010

To invoid TimeOut simple add:
// #####
curl_setopt( $curl, CURLOPT_HEADER, 0 );
curl_setopt($curl, CURLOPT_TIMEOUT, 25);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 20);
//#####

After "curl_setopt_array($curl, $options);"
around line 195

TuxX

TuxX wrote:
09/04/2010

@Omar
I'm afraid the password has to be send as plain text!!
Yes: shit!

TuxX

TuxX wrote:
09/04/2010

@Tim:

The service works as expected.

Please check $twit = new Twitter("username","password");

and replace "username" and "password" with your Account-Details.

Tim

Tim wrote:
09/04/2010

@TuxX I definitely have the correct username and password in the script. If I copy and paste into twitter website it logs me in fine.

Omar

Omar wrote:
09/04/2010

@Tim,
Look at the response from Tijs on 03/08/2009, he said something about commenting line 154, that solves the problem.

Thank you Tijs for this class, is very useful. You´re a master!

Laurent

Laurent wrote:
10/04/2010

There seems to be a problem with the "getFriends" method: The second optional parameter is called $cursor but the actual code uses a variable called $page.

The correct name should be $cursor and the parameter should also be called cursor in line 737 (version 1.0.5).

dev

dev wrote:
20/04/2010

Hi,

I am implementing this twitter class in my website. In that, i need the verify the user before retrieving the tweets. I have used the below code for doing verification, but am getting could not authenticate you message. Can you help me out to solve this issue?

include "twitter.php";
$twi_user = new Twitter("XXXXX","XXXXX");
$userid = $twi_user->verifyCredentials();

Robin Koorn

Robin Koorn wrote:
21/04/2010

Hi Tijs,

Bedankt voor dit mooi stukje programmeerwerk.

Ik vraag me alleen af hoe je de hyperlinks weer werkend kan krijgen....

gr.

Joshua

Joshua wrote:
21/04/2010

Hi

I am trying to use your API to get my status using - getStatus.

I took my id from my RSS feed. However when I try to use the getStatus. It is returning nothing (see code below).

include "twitter.php";
$twi_user = new Twitter("user","password");
print_r($twi_user->getStatus( id ));

Could someone help me out?

Tijs Verkoyen

Tijs Verkoyen wrote:
23/04/2010

@Michael: thx mate
@Tim: Tim, ran my tests again and everything is working fine, are you sure you use the correct credentials?
@Omar: the pass is sent as clear text, as required by Twitter.
@Robin: graag gedaan
@Jushua: I ran the tests again, and everything is working fine.
@Enrique: all text is utf8_decoded, did you try to remove the method?

meon

meon wrote:
27/04/2010

Will you update your class for supporting OAuth? As it will shut down on June 30th every application based on this class will stop functioning for authenticated requests...

Robin

Robin wrote:
28/04/2010

Hi Tijs,

Ik krijg de links in de tweets niet zichtbaar.
Enig idee hoe ik dit moet oplossen?

www.0318samen.nl

thanks

Bob

Bob wrote:
03/05/2010

I get this error. Can someone please help me? Thank you.


/statuses/update.xml Could not authenticate you. Unauthorized on line 229 in /home/xxxxxxxx/public_html/talkclassicrock.com/forums/includes/twitter.php
#0 /home/xxxxxxxx/public_html/talkclassicrock.com/forums/includes/twitter.php(648): Twitter->doCall('statuses/update...', Array, true)
#1 /home/xxxxxxxx/public_html/talkclassicrock.com/forums/newthread.php(273) : eval()'d code(33): Twitter->updateStatus('Test - http://i...')
#2 /home/xxxxxxxx/public_html/talkclassicrock.com/forums/newthread.php(273): eval()
#3 /home/xxxxxxxx/public_html/talkclassicrock.com/forums/vbseo.php(1382): require('/home/xxxxxxxx/...')
#4 {main}

Bob

Bob wrote:
04/05/2010

Do I need to actually put in my Twitter username and password in lines 110,111 respectively.

Also, my password has an exclamation point in it. Is that OK?

michael

michael wrote:
06/05/2010

@Bob: You need to instantiate the Twitter class with your username and password, like this:

$twitter = new Twitter('bob','mynameisbob!');

Or, you know, whatever your Twitter username and password is. Exclamation point is fine.

Bob

Bob wrote:
06/05/2010

@michael Thanks for your response. But, I'm not well versed with this. Which line? Add the code? Is the code already in there and just punch in the credentials?

Thanks.

Tijs Verkoyen

Tijs Verkoyen wrote:
06/05/2010

@meon: If I find some time...
@Rob: try Regular expressions
@michael: thanks mate.

Bob

Bob wrote:
06/05/2010

@Tijs Is that my homework or something? LOL. I'm trying to get it to work with a vbulletin2twitter mod. You're not going to give me the answer??

Thanks.

Bob

Bob wrote:
07/05/2010

How come in the thread of where I got this mod no one else has mentioned all the comments I've read here. In other words they never touched twitter.php. It just worked by direct download.

Bob

Bob wrote:
11/05/2010

Can someone (pretty) please provide me with an answer?

Where (at what line) and what code do I insert to get my vbulletin mod to work?

Thanks!!

Bob

Bob wrote:
11/05/2010

I have asked that person my friend. Unfortunately that person is now charging $$ for support.

I cannot pay for support at this point in time. Especially considering my problem seems to be a minor one. Secondly when the mod was first released it was free support. I just need to get it working and then I considering paying for future support.

Thanks. I shall look into this further.

Bob

Bob wrote:
11/05/2010

Ironically that guy says it your twitter.php

Also, no one else in that thread has once mentioned about creating an instance.

-Bob

Tijs Verkoyen

Tijs Verkoyen wrote:
11/05/2010

@Bob: really, I don't care if the guy says it is the class. I know it works, I know an instance should be created, it's called Object Oriented Programming.

Bob

Bob wrote:
13/05/2010

#1 Yes. I understand what you mean. I'm sure your class is working just fine. The guy creates an instance in his xml

#2 I've checked out the mod you mentioned. Above and it works with no errors but doesn't post/tweet to twitter

Tijs Verkoyen

Tijs Verkoyen wrote:
14/05/2010

@Andrew: Well, to be honest, I'm busy with the new version of the class, but I don't have the time I should have. I hope to release it on 1 June

Tijs Verkoyen

Tijs Verkoyen wrote:
14/05/2010

Somebody care to test the class with oAuth implemented?

developar

developar wrote:
15/05/2010

Yep, I am interested :)

Tijs Verkoyen

Tijs Verkoyen wrote:
15/05/2010

@Developar: see your mailbox

Jeff

Jeff wrote:
16/05/2010

Hi everyone, and especially Tijs!

As everyone says, your class is great. It makes implementing Twitter super easy.

I'm integrating it into a WordPress plugin and it has stopped working - but throws no errors.

I instantiate the object and any method I try to call never returns, never throws an error, and my script seem to move past it but also causes the page to fail.

I created a simple PHP page to create the instance and call the methods and it works perfectly (on the same server, outside of WordPress).

Chris

Chris wrote:
17/05/2010

Hi Tijs,
I have a Twitter mod which uses this class and everything was working fine till a week ago and now all of a sudden my users have reported that they are getting an error and when i tried, surprisingly(no code changes done inbetween) i also started getting this error -

exception 'TwitterException' with message 'Could not authenticate you' in /home/public_html/twitter/classes/twitter.php:204 Stack trace: #0 /home/public_html/twitter/classes/twitter.php(535): Twitter->doCall('statuses/user_t...', Array, true, false) #1

I have read all the comments above and I tried one of the solution mentioned above i.e.
un-commenting CURL_FOLLOWLOCATION line but I don't think my error is related to it as it was working fine before and moreover i never get that message about safe mode.

I am totally lost here and not sure if Twitter changed something on their end, so as a last hope, posting this message here for help....

Let me know.
Thanks
Chris

Chris

Chris wrote:
17/05/2010

And for your information, I am interested to test as well the new OAUTH version... :)

Tijs Verkoyen

Tijs Verkoyen wrote:
17/05/2010

@Jeff: seems like an issue with Wordpress. Did you try to enable the constant DEBUG? Maybe that helps you out.
@Chris: Is it working again? Maybe it has something to do with the availability of the API. Btw check your mailbox.

Jeff

Jeff wrote:
17/05/2010

Thanks Tijs.

I was testing with all of WordPress's debugging on. Turning on DEBUG in the twitter.php produced no visible output or logging that I could find.

It suddenly started working again. I'm not sure if I changed something or if Twitter was having a problem during my initial testing.

Looking forward to OAuth implementation.

Tijs Verkoyen

Tijs Verkoyen wrote:
17/05/2010

@Jeff: see your mailbox

Chris

Chris wrote:
18/05/2010

No Tijs, it's not working. I know that the authentication is working, since after i enter my username/password, it prompts for the deny/allow options and then once i click allow, it returns back to my site and throws that error, can you help?

Brunichi

Brunichi wrote:
08/06/2010

Hello! I'm testing the API but want to send messages to twitter I get the following error:

Fatal error: Cannot redeclare class twitterexception in \\hmfsw\web\dtcwin118\myweb.com\public_html\twitter.php on line 1868

you know what is due?.
Thanks!!!

motm

motm wrote:
15/06/2010

wauw, this class was really usefull and easy to implement!
thanx man!

Assis Antunes

Assis Antunes wrote:
08/07/2010

Exists a bug in "getUserTimeline" Method, don't need authenticate for to do this...

Line 535
$response = $this->doCall($url, $aParameters, true, false);

Correct
$response = $this->doCall($url, $aParameters, false, false);

Paul

Paul wrote:
09/07/2010

Hey.

I have been building an ExpressionEngine module using this class. It's been working perfectly locally, however no I've uploaded it I'm getting the following error:

/account/verify_credentials.xml Could not authenticate you.

Any ideas?

Dan

Dan wrote:
10/07/2010

There's the script that sends status updates to multiple accounts, that are all mine. With the basic authentification there're just 2 lines of code:

$twi_user = new Twitter($login,$password);
$twi_user->updateStatus($status);

But with the OAuth method I just don't get two basic things:
1. How do I at once allow all of mine accounts to be updated by my script (registered Twitter App, to be precise)?
2. Where do I put user's login and password in a script?

I know how it usually works — you get the Allow/Disallow message in a web browser and choose one of those options. But I don't have any human interaction, it all happens at the server side.

buzzknow

buzzknow wrote:
16/07/2010

Its really nice twitter class :D

thanks a lot ....

Joe

Joe wrote:
20/07/2010

First off, great twitter class. It's been working flawlessly up until about 10 hours ago. Below is the error message I'm getting. I have verified that my Twitter password is correct.

Fatal error: Uncaught exception 'TwitterException' with message 'invalid body' in /nfs/c01/h09/mnt/xxxx/data/twitter.php:541
Stack trace:
#0 /nfs/c01/h09/mnt/xxxx/data/xxxxxx.php(9): Twitter->getUserTimeline('xxxxxxxxxxxx')
#1 {main}
thrown in /nfs/c01/h09/mnt/xxxx/data/twitter.php on line 541

line 541 in twitter.php is:
if($xml == false) throw new TwitterException('invalid body');

Curious if you know what this error means. Thanks.

Joe

Joe wrote:
20/07/2010

Must have been an issue with Twitter because it's working again this morning. Disregard previous request.

About me?

Well, I'm Tijs Verkoyen, a self employed Belgian PHP-developer at Sumo Coders.

If you want to know more about me, check my blog (Dutch).

If you really like my work and want to support me, feel free to use the donate-button below.

Spoon

At both companies, we use Spoon. Spoon is a PHP5 Library that we use for building all our Web 2.0 applications.

The classes that you can download from this website are standalone, so each developer is free to use a library/framework/… he likes best.