Friday, May 3, 2013

Phirehose:Authorization Error when fetching tweets by Locations

Error

Error 401 UNAUTHORIZED

HTTP ERROR: 401

Problem accessing /1/statuses/filter.json. Reason: Unauthorized




Solution

UPDATED:

Solution #1

Check that your server time is in sync with twitter servers

Run this command and check the "date" part in response headers

GET -E https://api.twitter.com/1/help/test.json

and compare it with your server's date ( "date" shell command )

Make sure both are close enough or use ntp to auto sync your server



Solution #2

If it only happens when using "$sc->setLocations" function

The issue may also be related to missing location parameter when signing oAuth message

Add the following missing code at the end of getAuthorizationHeader() function, just before return $this->getOAuthHeader('POST', $url, $requestParams); in OauthPhirehose.php file




        if (count($this->locationBoxes) > 0)
        {
             $requestParams['locations'] = implode(',', $this->locationBoxes);
        }



No comments:

Post a Comment