Reputation: 151
I am using James Mallisons Twitter-API from Github: http://github.com/j7mbo/twitter-api-php
After passing the authentication credentials I try to get a list of tweets around defined geo coordinates:
$fields = "?q=test&geocode=".urlencode("$lat,$lon,$radius")."&count=100";
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$method = 'GET';
$result = $twitter->buildOauth($url, $method)
->setGetfield($fields)
->performRequest();
This generates the following CURL Opts to be set inside the api class: (masked auth credentials with XXX)
CURLOPT_HTTPHEADER => $header,
CURLOPT_HEADER => 'Authorization: OAuth oauth_consumer_key="XXX", oauth_nonce="XXX", oauth_signature_method="HMAC-SHA1", oauth_token="XXX", oauth_timestamp="XXX", oauth_version="1.0", oauth_signature="XXX"',
CURLOPT_URL => "https://api.twitter.com/1.1/search/tweets.json?q=test&geocode=48.39677%2C9.98042%2C35km&count=100",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false
A request made with this options results in the following error:
["message"]=>
string(26) "Could not authenticate you"
["code"]=>
int(32)
Do you have an idea about this error? Getting my friendlist from /friends/ids.json works great. So the authentication is correct. Seems to be an error with the query parameters.
Upvotes: 0
Views: 2705
Reputation: 26523
Note: I've +1'd Tim's answer, make sure you have the latest version ;)
Okay, your exact issue is that you don't need to urlencode()
your location stuff. It should be a plain old GET request.
According to the docs for geocode:
Example Values: 37.781157,-122.398720,1mi
Putting this into the getfield works:
$getfield = '?q=test&geocode=37.781157,-122.398720,1mi&count=100';
So make sure it's in the format according to the docs and you're good to go. I'll add this example to the wiki as well.
Upvotes: 1
Reputation: 8606
Looks like the author made a critical fix to encoding of commas just a few days ago. https://github.com/J7mbo/twitter-api-php/commit/5c2b97e402d04114ca3be6a793eebcd8521d76a5
My guess is that's why your geocode call fails and your friend/ids is fine. Best update the library.
Try mine if you're still stuck
Upvotes: 2