twitter search not working

intelaravind
@intelaravind Aravind S R

I want search for tweets in twitter. It is not working.

$parameters = array('q' => 'oauth');
$result = $connection->get('search', $parameters);
But when I do a user search it working perfectly.

$parameters = array('q' => 'oauth');
$result = $connection->get('users/search', $parameters);
I have also tried the below and that is also not working

$parameters = array('q' => 'oauth');
$result = $connection->get('search/tweets', $parameters);
What could be the reason?

1 year 27 weeks ago

Replies

intelaravind
@intelaravind Aravind S R

This is the error message. Could some one please help?

stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[message] => Sorry, that page does not exist
[code] => 34
)

)

)

1 year 26 weeks ago
abraham
@abraham Abraham Williams

TwitterOAuth only supports authenticated endpoints. The v1 API search method does not support auth. You can use v1.1 API search method which does support auth by doing the following.

  1. $connection->host = "https://api.twitter.com/1.1/";
1 year 26 weeks ago
intelaravind
@intelaravind Aravind S R

@abraham Thank you that helped :)

1 year 26 weeks ago
88ric
@88ric Richard Sunny

It didn't work out for me!

I changed:
public $host = "https://api.twitter.com/1.1/";
in "twitterouth.php" also tried writing the line :
$connection->host = "https://api.twitter.com/1.1/"; in index.php page.

@intelaravind can you please help in giving details, how it worked for you
@abraham or can you can elaborate how can i solve this issue?

1 year 24 weeks ago
CrewFinderApp
@CrewFinderApp CrewFinder App

I'm having the same problem. Any chance of a fix?

1 year 14 weeks ago
intelaravind
@intelaravind Aravind S R

@richardsunny sorry I missed your post. Please let me know if you still have problem

1 year 14 weeks ago
intelaravind
@intelaravind Aravind S R

@CrewFinderApp Did you try what abraham suggested? I tried that and it worked for me. What is the error message?

1 year 14 weeks ago
matthewcyan
@matthewcyan Matt Born

Had this same problem.

Use $connection->get('search/tweets', ... instead of get('search', ...

in conjunction with the $connection->host = "https://api.twitter.com/1.1/";

51 weeks 4 days ago
Sanchechin18
@Sanchechin18 Jose Antonio

i need used "sice_id",
could you help me where is the correct position?

i has $connection->get("search/tweets", array('q' => user),'sice_id'=>);

but i dont know if you need put the sice_id insite of array.

thanks

31 weeks 3 days ago
grey_mina
@grey_mina MinaGrey

might be a bit too late but here it is:

  1. session_start();
  2. require_once("twitteroauth.php"); //make sure it's the right path don't do like me
  3.  
  4. $query = "from:grey_mina&f=realtime"; //or whatever
  5. $consumerkey =  "12345"; //put yours here
  6. $consumersecret = "12345";  //put yours here
  7. $accesstoken ="12345";  //put yours here
  8. $accesstokensecret ="12345";  //put yours here
  9.  
  10. function getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret) {
  11.   $connection = new TwitterOAuth($consumerkey,  $consumersecret, $accesstoken, $accesstokensecret);
  12.   return $connection;
  13. }
  14.  
  15. $connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
  16.  
  17. $tweetstream = $connection->get("https://api.twitter.com/1.1/search/tweets.json?q=$query"); // & since_id= whatever&count=2 &result_type=recent etc.
  18. echo json_encode($tweetstream);  //this is a bit wild but so far it's the only way I have to print the result

something like that.

24 weeks 6 days ago