0

My question is similar to one here - Twitter search by hashtag example API v1.1. I've followed the API and advice as best as I can but I'm still a bit stuck on this one and wondering if someone can spot what i've done wrong:

<?php
require_once('twitter-api-php-master/TwitterAPIExchange.php');

$consumer_key = 'xxxx';
$consumer_secret = 'xxxx';
$oauth_access_token = 'xxxx';
$oauth_access_token_secret = 'xxxx';

// Your specific requirements
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$requestMethod = 'GET';
$getfield = '?q=#baseball&result_type=recent';

// Perform the request
$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
             ->buildOauth($url, $requestMethod)
             ->performRequest();
?>

It doesn't seem to be getting past ->buildOauth?? and isn't sending any messages to the screen. Can you see where I'm falling down?

DM2014
  • 3
  • 5
  • Have you tried it without the `#` character? It may be that the hash needs to be URL encoded. – Terence Eden Jan 01 '19 at 11:34
  • Thank you but that's not it. I've tried it both ways, encoded and not encoded. None of my queries are getting through, whether they use the hashtags or not, so I'm thinking it's to do with authentication but I can't see where. – DM2014 Jan 01 '19 at 11:42
  • Okay, so I've narrowed it down further. I've been testing on my local machine, thinking that my local web server would handle this in the same way. However, switching these scripts across to my public web server, they are working fine, so my question is now - what's the difference? What changes do I need to make to my local machine to make this work? – DM2014 Jan 01 '19 at 12:29
  • It might be the PHP version, the modules you have loaded, or any number of things. Have a look at http://php.net/manual/en/function.phpinfo.php on both machines and see what the differences are. – Terence Eden Jan 01 '19 at 14:04

0 Answers0