GithubHelp home page GithubHelp logo

jmathai / twitter-async Goto Github PK

View Code? Open in Web Editor NEW
532.0 532.0 125.0 772 KB

Twitter-async is a high performance wrapper for Twitter's OAuth API which provides parallel/asynchronous calls. Follow @apiclient for commit updates.

Home Page: http://wiki.github.com/jmathai/twitter-async

License: Other

PHP 8.72% CSS 2.12% HTML 89.16%

twitter-async's Introduction

Twitter-async (PHP)

A fast and asynchronous PHP Twitter library


How it looks

$twitterObj = new EpiTwitter($consumerKey, $consumerSecret, $oauthToken, $oauthSecret);  
$creds = $twitterObj->get('/account/verify_credentials.json');  
var_dump($creds->response);

Documentation:

Live Example

Blogs

Authors

Jaisen Mathai
jaisen-at-jmathai.com
http://www.jaisenmathai.com

Contributions from

twitter-async's People

Contributors

aaronwaldon avatar arikfr avatar ashcairo avatar danieljonesorg avatar dingram avatar dustyreagan avatar ericmmartin avatar jmathai avatar ksg91 avatar luukas avatar nealpoole avatar squio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twitter-async's Issues

getAuthorization returns "Failed to validate oauth signature or token"

This issue was closed as unreplicable, however I am getting the same error today with code that worked yesterday! Strangely the sample code application works fine. I tried renewing my application's consumer_key and consumer_secret on Twitter but it makes no difference, I still get a 401 error return.

Presumably it has something to do with the potential OAuth security exploit, but I see nothing about Twitter currently suspending OAuth for some applications (which wouldn't make much sense anyhow, a potential attack would be most likely against an exisitng application with a large client base).

Here is a very little test application (2 lines thanks to the API!) that replicates the problem:

include 'EpiCurl.php'; include 'EpiOAuth.php'; include 'EpiTwitter.php';

$twitterObj = new EpiTwitter('---key---', '---secret---');

echo 'authorization URL = ' . $twitterObj->getAuthorizationUrl();

Fatal error: Uncaught exception 'EpiOAuthUnauthorizedException' with message
'Failed to validate oauth signature and token' in ... /EpiOAuth.php:272
Stack trace: #0 ... EpiOAuth.php(251): EpiOAuthException::raise('Failed to valid...', 401)

FOLLOWLOCATION does not work for POST requests

When Twitter sends 301 or 302s for POSTs the FOLLOWLOCATION option does not work. The solution appears to be to manually follow the request by inspecting the return code and Location header.

EpiCurl causes CPU spike under heavy usage (reported by @alombarte

Debugging information from the server the problem was seen on:

PING twitter.com (128.121.146.228) 56(84) bytes of data.
64 bytes from 128.121.146.228: icmp_seq=1 ttl=240 time=160 ms
64 bytes from 128.121.146.228: icmp_seq=2 ttl=240 time=158 ms 64 bytes from 128.121.146.228: icmp_seq=3 ttl=240 time=162 ms 64 bytes from 128.121.146.228: icmp_seq=4 ttl=240 time=165 ms 64 bytes from 128.121.146.228: icmp_seq=5 ttl=240 time=165 ms

PING search.twitter.com (128.121.146.107) 56(84) bytes of data.
64 bytes from 128.121.146.107: icmp_seq=1 ttl=240 time=171 ms
64 bytes from 128.121.146.107: icmp_seq=2 ttl=240 time=175 ms 64 bytes from 128.121.146.107: icmp_seq=3 ttl=240 time=170 ms 64 bytes from 128.121.146.107: icmp_seq=4 ttl=240 time=175 ms

$ time curl http://twitter.com/statuses/public_timeline.xml real 0m0.888s user 0m0.004s sys 0m0.000s

curl --trace-time http://twitter.com/statuses/public_timeline.xml > test.test % Total % Received % Xferd Average Speed Time Time Time Current

                         Dload  Upload   Total   Spent    Left  Speed

100 18535 100 18535 0 0 8513 0 0:00:02 0:00:02 --:--:-- 9593

DELETE not implemented

Trying to use DELETE to remove a subscription from a list... however DELETE isn't implemented by the looks of things :(

Implement CURLOPT_INTERFACE

This is in regards to a shared hosting environment where the actual calls to the Twitter api are routed through a different ip than the one specified in the cpanel(even if its dedicated). Most hosters use different inbound and outbound ip addresses. So i require to use CURLOPT_INTERFACE to specify which ip to use. (this necessary if the ip is whitelisted)

As a quick fix i've added the following code after line no. 38 in EpiTwitter.php

curl_setopt($ch, CURLOPT_INTERFACE, $_SERVER ['SERVER_ADDR']);

This fixed my problem. I hope its integrated in the next version. :-)

Regards,
Ajinkya

Add compression option to library

It would be great if you would allow clients using your library to set the "Accept-Encoding: gzip, deflate" HTTP header. This way Twitter will compress its response to the client, and considering the amount of redundant/duplicate data we all get back from Twitter, this should lead to a significant decrease in bandwidth...

godaddy support?

Your api was awesome on my mac... but when i uploaded to my godaddy server i get this :( Does this mean it's failing on cURL?

Fatal error: Uncaught exception 'EpiOAuthException' in /home/content/j/a/c/jacobthornton/html/lemonade/php/twitter/EpiOAuth.php:375 Stack trace: #0 /home/content/j/a/c/jacobthornton/html/lemonade/php/twitter/EpiOAuth.php(345): EpiOAuthException::raise(Object(EpiCurlManager), NULL) #1 /home/content/j/a/c/jacobthornton/html/lemonade/php/twitter/EpiOAuth.php(345): EpiOAuthResponse->__get('debug') #2 /home/content/j/a/c/jacobthornton/html/lemonade/php/twitter/EpiOAuth.php(40): EpiOAuthResponse->__get('oauth_token') #3 /home/content/j/a/c/jacobthornton/html/lemonade/php/twitter/start.php(9): EpiOAuth->getAuthenticateUrl() #4 {main} thrown in /home/content/j/a/c/jacobthornton/html/lemonade/php/twitter/EpiOAuth.php on line 375

Uncaught exception 'EpiOAuthException'

Here's my code:

getAuthenticateUrl(); ?>

And am receiving the following error:

Fatal error: Uncaught exception 'EpiOAuthException' in /var/www/html/sites/all/modules/twitter_async/EpiOAuth.php:346 Stack trace: #0 /var/www/html/sites/all/modules/twitter_async/EpiOAuth.php(323): EpiOAuthException::raise(NULL, NULL) #1 /var/www/html/sites/all/modules/twitter_async/EpiOAuth.php(39): EpiOAuthResponse->__get('oauth_token') #2 /var/www/html/sites/all/modules/twitter_async/t.php(7): EpiOAuth->getAuthenticateUrl() #3 {main} thrown in /var/www/html/sites/all/modules/twitter_async/EpiOAuth.php on line 346

Incase it helps I have PHP 5.1.6

CURLOPT_FOLLOWLOCATION errors on shared server

I was getting this error below when using the oauth_callback on a shared server. It wasn't stopping it from working, but just got lots of errors appearing in the page

Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in ...../epitwitter/EpiOAuth.php on line 142

Adding this if statement to line 142 seems to have cured it

if (ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off'))
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

account/end_session not working

Hi!
Trying to logout from twitter with help of post_accountEnd_session() .
But it is not working, user is still logged in.
I receive response smth. like "error":"Logged out."
Please, could you tell me what can be the problem?
thx!

get_statusesRetweets problem

Here's my code, it is likely that I am not doing something right.

$params = array('count' => 200, 'since_id' => $since);
$tweets= $twitterObj->get_statusesRetweets_of_me($params);
$tweets->response;
foreach($tweets as $status) {
                // use tweet_id to get all retweets of this tweet
                $params = array('id' => $status->id, 'count' => 100);
                $retweets= $twitterObj->get_statusesRetweets($params);
                //$retweets= $twitterObj->get("/statuses/retweets.json", ($params));
                $retweets->response;
                foreach($retweets as $retweet) {
                         // do something with the retweet
                }

The error message I get back is this:

Fatal error: Uncaught exception 'EpiTwitterNotFoundException' with message '{"request":"/1/statuses/retweets.json?id=5844348308&count=100","error":"Not found"}' in /home/content/a/r/k/arkovi/html/dev/twitterasync/EpiTwitter.php:259 Stack trace: #0 /home/content/a/r/k/arkovi/html/dev/twitterasync/EpiTwitter.php(220): EpiTwitterException::raise(Object(EpiCurlManager), false) #1 /home/content/a/r/k/arkovi/html/dev/twitterasync/EpiTwitter.php(177): EpiTwitterJson->__get('__obj').......

It seems odd that it is requesting /1/statuses/retweets.json instead of /statuses/retweets.json, but maybe that is normal.

Any thoughts?

Update twiiter API URL to cater for API versioning

As per this thread:
http://groups.google.com/group/twitter-development-talk/browse_thread/thread/2b70bd6ea4aec175

The twitter API URL is changing to support versioning so:

http://twitter.com/users/show/noradio.xml

becomes

http://api.twitter.com/1/users/show/noradio.xml

From the thread:

'We also don't have a hard date for when API requests to
http://twitter.com will no longer be serviced. We aren't planning on
pulling the rug out from anyone though. Please update your
applications to the new http://api.twitter.com/1 at your soonest
convenience. The non API urls likely won't be supported forever. '

getAuthenticateUrl() Timing Out Every Time

I downloaded example script from blog, which has older version of twitter-async files, tested it on my server, and works fine. Then replace the 3 core files (EpiCurl, EpiTwitter, and EpiOAuth) with latest on github, go back to start.php with no other changes and its sits there for few minutes then times out... any suggestion, or is there a different way to getAuthenticateUrl??

Pagination using the Twitter cursor paramater (required)

First let me say I appreciate you putting together this library. This problem results when using the EpiCurl.php EpiTwitter.php and EpiOauth.php files intact without modification.

While programming in vb.net I noticed that you could no longer call pages of followers, following, blocks, etc using the page paramater. Twitter is now using the cursor parameter. I have set up a sample page attempting to properly paginate through the friends using the get_statusesFriends() method of your API. The code has three states that I can comment out and un-comment in order to test.

I am reticent to start mucking around in the three main classes and so I am asking you if you have a solution to this. I look forward to hearing from you.

Regards,

Bob Cristello
TweetClean

reference: http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses%C2%A0friends

get_statusesFriends();  
    //state 2 - returns next_cursor but no users
    $twitterFriendInfo=$twitterObj->get_statusesFriends(array('cursor' => '-1')); 
    //state 3 - returns no next_cursor and no users
    $twitterFriendInfo = $twitterObj->get('statuses/friends.json?cursor=-1');
    
    $twitterFriendInfo->response;
    

    // Loop over the response as an an array
    foreach($twitterFriendInfo as $follower){
        echo $follower['screen_name'];
        echo '
'; } echo "Next Cursor: ".$twitterFriendInfo->next_cursor; }catch(EpiTwitterException $e){ echo 'We caught an EpiOAuthException'; echo $e->getMessage(); }catch(Exception $e){ echo 'We caught an unexpected Exception'; echo $e->getMessage(); } ?>

Headers get duplicated with each call.

From @mulka

Here's an interesting bug I ran into... each Twitter API request
through twitter-async adds on more HTTP headers instead of replacing
them.

So, the first one has three headers:
Expect:
Authorization:
User-Agent:

The second one has six, basically duplicating the first three.
Expect:
Authorization:
User-Agent:
Expect:
Authorization:
User-Agent:

The third request has nine, and so on. After a certain number of
request headers (about 150), Twitter gives back an HTTP 400 error
saying that the server can't accept that many request headers.

This code (with valid authentication info) consistently throws an
exception on about the 50th loop.

$t = new EpiTwitter(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);
$t->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);

for($i = 0; $i < 60; $i++){
        print "$i\n";
        $result = $t->get_usersShow(array('screen_name' => 'mulka'));
        $result->response;

}

Here's the exception:

Fatal error: Uncaught exception 'EpiOAuthBadRequestException' with
message '
 <title>400 Bad Request</title>  

Bad Request

Your browser sent a request that this server could not understand.
The number of request header fields exceeds this server's limit.

' in /home/mulka/twilk/includes/EpiOAuth.php:337 Stack trace: #0 /home/mulka/twilk/includes/EpiTwitter.php(139): EpiOAuthException::raise('__get('response') #2 {main} thrown in /home/mulka/twilk/includes/EpiOAuth.php on line 337

EpiOAuthUnauthorizedException

This is an error thrown to some users of http://theunfollowapp.com. Most users never get this error. I cannot reproduce it. It occurs when a user tries to unfollow. Any idea what this might be? Thank you

Fatal error: Uncaught exception 'EpiOAuthUnauthorizedException' with message '{"request":"/friendships/destroy.json" ,"error" :"Read-only application cannot POST"}' in
/home/content/45/4665545/html/theunfollowapp/EpiOAuth.php:249 Stack trace: #0
/home/content/45/4665545/html/theunfollowapp/EpiTwitter.php(100):
EpiOAuthException::raise('{"request": "/fr ... ', 401) #1 /home/content/45/4665545
/html/theunfollowapp/unfollow.php(13): EpiTwitterJson-> get('id') #2 {main} thrown In
/home/content/45/4665545/html/theunfollowapp/EpiOAuth.php on line 249

statuses/update returns "Failed to validate oauth signature or token" when using in_reply_to_status_id parameter

I'm using the latest github code.

This is my php code:

$status = "@LeeronShalev testing: One, Two";
$replytoid = "1786937496";
$twitterObj = new EpiTwitter("wMt3sA5PC8W2EkK7I4juFQ", "eqxAY17ZRjpYUkOXH32nCfb9Mzm1fYWtZxsY7RKZu2U", "41332266-7sV6od4pKcOjWLGMctjWN6ccknLg0VOO60eLc3eft", "ylcmFhT0n3eHaXVYvi2A9MgblXyZwLg91K9QLqxXEGc");
$st = $twitterObj->post_statusesUpdate(array('status' => $status, 'in_reply_to_status_id' => $replytoid));

And that's the HTTP request data:

POST /statuses/update.json HTTP/1.1
Host: twitter.com
Accept: */*
Authorization: OAuth realm="http://twitter.com/statuses/update.json",oauth_consumer_key="wMt3sA5PC8W2EkK7I4juFQ",oauth_token="41332266-7sV6od4pKcOjWLGMctjWN6ccknLg0VOO60eLc3eft",oauth_nonce="edc3eee1c4b6147361f2e5b15c8f158b",oauth_timestamp="1242827526",oauth_signature_method="HMAC-SHA1",oauth_version="1.0",oauth_signature="37G8Se8law9udqVG39plTHpSEas%3D"
Content-Length: 81
Content-Type: application/x-www-form-urlencoded

status=%40LeeronShalev+testing%3A+One%2C+Two&amp;in_reply_to_status_id=1786937496

-------------------------------------------------------------------------

HTTP/1.1 401 Unauthorized
Date: Wed, 20 May 2009 13:52:06 GMT
Server: hi
Status: 401 Unauthorized
Cache-Control: no-cache, max-age=300
Content-Type: text/html; charset=utf-8
Content-Length: 43
Set-Cookie: _twitter_sess=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%250ASGFzaHsABjoKQHVzZWR7AA%253D%253D--1164b91ac812d853b877e93ddb612b7471bebc74; domain=.twitter.com; path=/
Expires: Wed, 20 May 2009 13:57:06 GMT
Vary: Accept-Encoding
Connection: close

Failed to validate oauth signature or token

When the in_reply_to_status_id parameter is omitted the request works fine.

PHP code:

$status = "testing: One, Two";
$twitterObj = new EpiTwitter("wMt3sA5PC8W2EkK7I4juFQ", "eqxAY17ZRjpYUkOXH32nCfb9Mzm1fYWtZxsY7RKZu2U", "41332266-7sV6od4pKcOjWLGMctjWN6ccknLg0VOO60eLc3eft", "ylcmFhT0n3eHaXVYvi2A9MgblXyZwLg91K9QLqxXEGc");
$st = $twitterObj->post_statusesUpdate(array('status' => $status));

Request data:

POST /statuses/update.json HTTP/1.1
Host: twitter.com
Accept: */*
Authorization: OAuth realm="http://twitter.com/statuses/update.json",oauth_consumer_key="wMt3sA5PC8W2EkK7I4juFQ",oauth_token="41332266-7sV6od4pKcOjWLGMctjWN6ccknLg0VOO60eLc3eft",oauth_nonce="2bf4d5326d873f83d0d175c4b0d06798",oauth_timestamp="1242828075",oauth_signature_method="HMAC-SHA1",oauth_version="1.0",oauth_signature="F%2BWiEu2BHl1T0FbnO3H446l8Vo4%3D"
Content-Length: 28
Content-Type: application/x-www-form-urlencoded

status=testing%3A+One%2C+Two

------------------------------------------------------------------------

HTTP/1.1 200 OK
Date: Wed, 20 May 2009 14:01:17 GMT
Server: hi
Last-Modified: Wed, 20 May 2009 14:01:18 GMT
Status: 200 OK
ETag: "6c85095f8e9ef5e72fa15b7b9203b802"
Pragma: no-cache
Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
Content-Type: application/json; charset=utf-8
Content-Length: 996
Expires: Tue, 31 Mar 1981 05:00:00 GMT
X-Revision: 9e993dc809403467fb717e688f5ed2ed55d6c9b3
X-Transaction: 1242828078-49194-19492
Set-Cookie: _twitter_sess=BAh7BzoHaWQiJTg2NjUzNmVlZjVhZDFkNjVkMTIyNTFjYTVjNTkyMGJjIgpm%250AbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewAG%250AOgpAdXNlZHsA--15dba2a59b16c585966c03b824abe0881b9c197d; domain=.twitter.com; path=/
Vary: Accept-Encoding
Connection: close

{"in_reply_to_status_id":null,"created_at":"Wed May 20 14:01:18 +0000 2009","user":{"profile_background_image_url":"http:\/\/static.twitter.com\/images\/themes\/theme1\/bg.gif","description":null,"time_zone":null,"utc_offset":null,"created_at":"Wed May 20 10:25:16 +0000 2009","profile_link_color":"0000ff","profile_background_tile":false,"profile_image_url":"http:\/\/static.twitter.com\/images\/default_profile_normal.png","profile_background_color":"9ae4e8","favourites_count":0,"url":null,"screen_name":"leeronTest","name":"Leeron's Test User","following":false,"notifications":false,"statuses_count":1,"profile_sidebar_fill_color":"e0ff92","protected":false,"profile_sidebar_border_color":"87bc44","followers_count":0,"friends_count":0,"location":null,"id":41332266,"profile_text_color":"000000"},"truncated":false,"text":"testing: One, Two","in_reply_to_user_id":null,"favorited":false,"in_reply_to_screen_name":null,"id":1859360957,"source":"<a href=\"http:\/\/toki.dev\">Leeron Dev<\/a>"}

oauth_token timeout

Hi

When using getAuthorizeUrl() the oauth_token only seems to be valid for a limited time, about15 mins I think. If you click after a certain time then the login is rejected on Twitter with:

"This page is no longer valid. It looks like someone already used the token information you provided. Please return to the site that sent you to this page and try again โ€ฆ it was probably an honest mistake."

Is this a problem or should a getAuthorizeUrl() only be called just before making a login request?

Thanks

curlInit breaks if web server sits behind a (local) proxy

In this situation, the web server will receive requests as 127.0.0.1, which is not a good interface for curl'ing out.

149 if(isset($_SERVER ['SERVER_ADDR']) && !empty($_SERVER['SERVER_ADDR']))
150 curl_setopt($ch, CURLOPT_INTERFACE, $_SERVER ['SERVER_ADDR']);

Library fails when updating a status starting with @

Attempted to post a status to Twitter starting with a @.

The library ends up calling EpiTwitter::request_basic with the method POST, executing the API call "statuses/update", and the request fails with an http result code of 0. Putting a space in front of the @ sign works. This is probably related to this item in the PHP CURL documentation:

CURLOPT_POSTFIELDS - The full data to post in a HTTP "POST" operation. To post a file, prepend a filename with @ and use the full path. This can either be passed as a urlencoded string like 'para1=val1&para2=val2&...' or as an array with the field name as key and field data as value. If value is an array, the Content-Type header will be set to multipart/form-data.

EpiTwitter references deprecated timeout parameter

chrisbraddock said 20 minutes ago:

It looks like you renamed/removed OAuth's timeout property but EpiTwitter is still referencing it. If I had more time I'd look in to this more ... probably take you two seconds. I'm still trying to stumble my way around github...

Thanks for the great code.

Parameters not encoded in GET requests

Just noticed that the parameters in a GET requests aren't getting encoded. There's a call to array_walk($params, array($this, 'encode_rfc3986')); which does nothing since array_walk requires the callback to accept the parameter by reference and change it instead of returning the changed value.
Fixing the callback to accept the value by reference will expose a new bug in POST requests since httpPost uses http_build_query on the parameters causing them to be encoded twice.

Great project by the way :)
Liron

safari thinks i have an invalid access_token? what.

For some reason safari refuses to let me connect (while other browsers are just fine with this. any ideas?)

Fatal error: Uncaught exception 'EpiOAuthUnauthorizedException' with message ' /oauth/access_token Invalid / expired Token ' in /home/content/j/a/c/jacobthornton/html/lemonade/php/twitter/EpiOAuth.php:249 Stack trace: #0 /home/content/j/a/c/jacobthornton/html/lemonade/php/twitter/EpiOAuth.php(228): EpiOAuthException::raise('<?xml version="...', 401) #1 /home/content/j/a/c/jacobthornton/html/lemonade/php/twitter/confirm2.php(11): EpiOAuthResponse->__get('oauth_token') #2 {main} thrown in /home/content/j/a/c/jacobthornton/html/lemonade/php/twitter/EpiOAuth.php on line 249

Untitled

I'm using the latest github code.
This is my php code:

$status = "@LeeronShalev testing: One, Two";
$replytoid = "1786937496";
$twitterObj = new EpiTwitter("wMt3sA5PC8W2EkK7I4juFQ", "eqxAY17ZRjpYUkOXH32nCfb9Mzm1fYWtZxsY7RKZu2U", "41332266-7sV6od4pKcOjWLGMctjWN6ccknLg0VOO60eLc3eft", "ylcmFhT0n3eHaXVYvi2A9MgblXyZwLg91K9QLqxXEGc");
$st = $twitterObj->post_statusesUpdate(array('status' => $status, 'in_reply_to_status_id' => $replytoid));

And that's the HTTP request data:

POST /statuses/update.json HTTP/1.1
Host: twitter.com
Accept: /
Authorization: OAuth realm="http://twitter.com/statuses/update.json",oauth_consumer_key="wMt3sA5PC8W2EkK7I4juFQ",oauth_token="41332266-7sV6od4pKcOjWLGMctjWN6ccknLg0VOO60eLc3eft",oauth_nonce="edc3eee1c4b6147361f2e5b15c8f158b",oauth_timestamp="1242827526",oauth_signature_method="HMAC-SHA1",oauth_version="1.0",oauth_signature="37G8Se8law9udqVG39plTHpSEas%3D"
Content-Length: 81
Content-Type: application/x-www-form-urlencoded

status=%40LeeronShalev+testing%3A+One%2C+Two&in_reply_to_status_id=1786937496


HTTP/1.1 401 Unauthorized
Date: Wed, 20 May 2009 13:52:06 GMT
Server: hi
Status: 401 Unauthorized
Cache-Control: no-cache, max-age=300
Content-Type: text/html; charset=utf-8
Content-Length: 43
Set-Cookie: _twitter_sess=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%250ASGFzaHsABjoKQHVzZWR7AA%253D%253D--1164b91ac812d853b877e93ddb612b7471bebc74; domain=.twitter.com; path=/
Expires: Wed, 20 May 2009 13:57:06 GMT
Vary: Accept-Encoding
Connection: close

Failed to validate oauth signature or token


When I'm omiting the in_reply_to_status_id parameter the request works fine.
PHP code:

$status = "testing: One, Two";
$twitterObj = new EpiTwitter("wMt3sA5PC8W2EkK7I4juFQ", "eqxAY17ZRjpYUkOXH32nCfb9Mzm1fYWtZxsY7RKZu2U", "41332266-7sV6od4pKcOjWLGMctjWN6ccknLg0VOO60eLc3eft", "ylcmFhT0n3eHaXVYvi2A9MgblXyZwLg91K9QLqxXEGc");
$st = $twitterObj->post_statusesUpdate(array('status' => $status));

Request data:

POST /statuses/update.json HTTP/1.1
Host: twitter.com
Accept: /
Authorization: OAuth realm="http://twitter.com/statuses/update.json",oauth_consumer_key="wMt3sA5PC8W2EkK7I4juFQ",oauth_token="41332266-7sV6od4pKcOjWLGMctjWN6ccknLg0VOO60eLc3eft",oauth_nonce="2bf4d5326d873f83d0d175c4b0d06798",oauth_timestamp="1242828075",oauth_signature_method="HMAC-SHA1",oauth_version="1.0",oauth_signature="F%2BWiEu2BHl1T0FbnO3H446l8Vo4%3D"
Content-Length: 28
Content-Type: application/x-www-form-urlencoded

status=testing%3A+One%2C+Two


HTTP/1.1 200 OK
Date: Wed, 20 May 2009 14:01:17 GMT
Server: hi
Last-Modified: Wed, 20 May 2009 14:01:18 GMT
Status: 200 OK
ETag: "6c85095f8e9ef5e72fa15b7b9203b802"
Pragma: no-cache
Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
Content-Type: application/json; charset=utf-8
Content-Length: 996
Expires: Tue, 31 Mar 1981 05:00:00 GMT
X-Revision: 9e993dc809403467fb717e688f5ed2ed55d6c9b3
X-Transaction: 1242828078-49194-19492
Set-Cookie: _twitter_sess=BAh7BzoHaWQiJTg2NjUzNmVlZjVhZDFkNjVkMTIyNTFjYTVjNTkyMGJjIgpm%250AbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewAG%250AOgpAdXNlZHsA--15dba2a59b16c585966c03b824abe0881b9c197d; domain=.twitter.com; path=/
Vary: Accept-Encoding
Connection: close

{"in_reply_to_status_id":null,"created_at":"Wed May 20 14:01:18 +0000 2009","user":{"profile_background_image_url":"http://static.twitter.com/images/themes/theme1/bg.gif","description":null,"time_zone":null,"utc_offset":null,"created_at":"Wed May 20 10:25:16 +0000 2009","profile_link_color":"0000ff","profile_background_tile":false,"profile_image_url":"http://static.twitter.com/images/default_profile_normal.png","profile_background_color":"9ae4e8","favourites_count":0,"url":null,"screen_name":"leeronTest","name":"Leeron's Test User","following":false,"notifications":false,"statuses_count":1,"profile_sidebar_fill_color":"e0ff92","protected":false,"profile_sidebar_border_color":"87bc44","followers_count":0,"friends_count":0,"location":null,"id":41332266,"profile_text_color":"000000"},"truncated":false,"text":"testing: One, Two","in_reply_to_user_id":null,"favorited":false,"in_reply_to_screen_name":null,"id":1859360957,"source":"<a href="http://toki.dev">Leeron Dev</a>"}

EpiCurlManager::__get

now it is
function __get($name)
{
$responses = $this->epiCurl->getResult($this->key);
return $responses[$name];
}

but, maybe, i should be:
function __get($name)
{
$responses = $this->epiCurl->getResult($this->key);
return isset( $responses[$name] ) ? $responses[$name] : null;
}

get all friends screen names (usernames)

i am looking through the twitter docs and dev group, figured i would ask here.
whats the most efficient way to return a complete list of a users friends usernames/screen_names?
do i need to first use get_friendsIds and then foreach id, do a get_usersShow? that seems very inefficient. am i missing a better approach? i will store this data locally but still.

i started with get_statusesFriends but this is not a complete list of friends in a single call. i would have to specify the page # to go deeper into the list. not sure if i can detect how many pages exist. so only 100 results at a time. and i dont need the actual last status of each friend. i just want a list of ids and usernames.

thanks.

Support for regular curl instead of curl_multi

I am not able to to twitter search on PHP 5.1 but works on PHP 5.2.

When I var_dump the response the only difference I find is that object(EpiCurl) resource is of type (curl_multi) on PHP 5.2 and object(EpiCurl) resource is of type (curl) when I run it on PHP 5.1

I guess the code support curl_multi and not regular curl

Problem with screennames that get sliced to parts

In some of the API endpoints the screen_name/id is part of the URI, like with the block create, i.e.:
http://twitter.com/blocks/create/{id}.json
Where id is either screenname or user id. In such cases we can use a hack to make the screenname/id part of the uri like:
$method = "post_blocksCreate/{$screen_name}";
$response = $twitter->$method();

Which works fine until the screen name has _ in it or is made of a name and number (i.e. hsumioka2002) and than the URI that being created is:
http://twitter.com/blocks/create/hsumioka/2002.json
Which is... well, not working :)

Possible workaround: add two additional parameter besides the array that can be either the screen_name or id and will be appended to the uri at the end.

How can you access a Twitter status?

I am trying to access Twitter statuses using the API but the problem is that there needs to be a number following the trailing slash. Since you can't capitalise a number, is there a way to tell the script to insert a slash?

To access a path like this:
statuses/show/1472669360

I would try
get_statusesShow1472669360

But the script tries to access:
statuses/show1472669360

Any idea on how to do this?

post_accountUpdate_profile_background_image method - incorrect signature

I am experiencing an issue when using the "post_accountUpdate_profile_background_image" method with twitter-async. I have the users token and secret set onto my EpiTwitter object and other calls work fine without returning any error, namely "get_accountVerify_credentials()" and "post_accountUpdate_profile_colors". These calls work fine and the expected results happens with no error.

When I try to use "post_accountUpdate_profile_background_image", I receive the error "{"request":"/account/update_profile_background_image.json","error":"Incorrect signature"}" and the background is not changed. Here is the code I am using:

$sendBg = $twitterObj->post_accountUpdate_profile_background_image(array('@image' => '@/home/tim/public_html/tweetground/' . $backgroundDetails["image_path"]));
echo $sendBg->responseText . "
";

Is this a bug or am I doing something wrong?

get_friendsIds get_statusesFriends etc. not returning data

trying to figure out if their is something wrong with twitter-asynch or twitter api or my end.
i can get auth to work and return get_accountVerify_credentials data but when i try to use an endpoint for getting friend/follower lists, i get nadda. i saw a comment or 2 from others having similar problem. i've tried both older relased code and most recent from github. no joy.

http://twitter.com/friends/ids.json for example does show the data to be present.

can this be confirmed or thoughts on what i might be doing wrong? the exact code provided does not work so i have not altered anything.

thanks.

Expose headers from the response

From @justinvincent

$twitterObj = new EpiTwitter();
$result = $twitterObj->get_trends();
 
print $result->headers; // raw text headers
 
// Changes....
 
EpiTwitter.php - Line 148
$this->headers      = $this->__resp->headers;
 
EpiCurl.php - Line 36
public function addCurl($ch)
{
    curl_setopt($ch, CURLOPT_HEADER, 1);
 
EpiCurl.php - Line 94
private function storeResponses()
  {
    while($done = curl_multi_info_read($this->mc))
    {
      $key = (string)$done['handle'];
  
      $buff = preg_split('/Connection: close[\r\n]/',curl_multi_getcontent($done['handle']));
 
      $this->responses[$key]['headers'] = trim($buff[0]);
      $this->responses[$key]['data']    = trim($buff[1]);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.