I'm tying to use J7mbo's twitter-api-php to search for tweets with certain keywords. But every time I run my code, I get
{"errors":[{"code":32,"message":"Could not authenticate you."}]}
I tried to run the example code here and it works fine with getting the user's timeline. Also tried running my search on the command line using the Twitter's signature generator and everything works fine with my keys and tokens.
That authentication error occurs when I run the following code
$settings = array(
'consumer_key' => '...',
'consumer_secret' => '...',
'oauth_access_token' => '...',
'oauth_access_token_secret' => '...'
);
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$twitter = new TwitterAPIExchange($settings);
$fields = '?q=twitter';
$response = $twitter->setGetfield($fields)->buildOauth($url, 'GET')
->performRequest();
As I looked into the code inTwitterAPIExchange
class and in the example code here, it seems that when the query parameters is appended to CURLOPT_URL
, the error would appear. But I don't know if that's really the reason, neither how to fix it if that's the case. Any help for this is greatly appreciated.