Streaming api always shows timeout error while using tmhOAuth lib with php

SelviKaruppanan
@SelviKaruppanan Selvi Karuppanan

I have created the program for getting tweets from twitter using streaming api.
For that I have used tmhOAuth library with PHP.
My code always shows timeout error.
Can any one tell me how to write the program to getting tweets with follow id using streaming api?
Any suggestions would be appreciated!!!

1 year 22 weeks ago

Replies

kurrik
@kurrik Arne Roomann-Kurrik

Where are you seeing the timeout error? How are you running the PHP script? (hint: if you're not executing it via the command line, you're doing it wrong - see the instructions in https://github.com/themattharris/tmhOAuth/blob/master/examples/streaming.php).

1 year 22 weeks ago
SelviKaruppanan
@SelviKaruppanan Selvi Karuppanan

Thanks for your reply Arne!
I have used the following code,

  1. <?php
  2. function my_streaming_callback($data, $length, $metrics) {
  3.   echo $data .PHP_EOL;
  4.   return file_exists(dirname(FILE) . '/STOP');
  5. }
  6. require '../tmhOAuth.php';
  7. require '../tmhUtilities.php';
  8. $tmhOAuth = new tmhOAuth(array(
  9.   'consumer_key'    => 'CONSUMER_KEY',
  10.   'consumer_secret' => 'CONSUMER_SECRET',
  11.   'user_token'      => 'USER_TOKEN',
  12.   'user_secret'     => 'USER_SECRET',
  13. ));
  14.  
  15. $method = 'https://stream.twitter.com/1/statuses/filter.json';
  16. $params = array(
  17. 'follow'    => 'xxxxxxxxx',
  18. );
  19. $tmhOAuth->streaming_request('POST', $method, $params, 'my_streaming_callback');
  20. tmhUtilities::pr($tmhOAuth);
  21. ?>

But while using track instead of follow I got the resulted tweets,

  1. $params = array(
  2. 'track'    => 'Twitter',
  3. );

when using follow only I got empty string as result, refer below result

string ' ' (length=2)

array
'start' => int 1336751048
'interval_start' => int 1336751048
'tweets' => int 1
'last_tweets' => int 0
'bytes' => int 0

'last_bytes' => int 0

What's problem exist here?

1 year 22 weeks ago
SelviKaruppanan
@SelviKaruppanan Selvi Karuppanan

Can I run it in browser?

1 year 22 weeks ago
SelviKaruppanan
@SelviKaruppanan Selvi Karuppanan

Thanks for your suggestion Arne!
I have used the following code,

  1. <?php
  2. function my_streaming_callback($data, $length, $metrics) {
  3.   echo $data .PHP_EOL;
  4.   return file_exists(dirname(FILE) . '/STOP');
  5. }
  6. require '../tmhOAuth.php';
  7. require '../tmhUtilities.php';
  8. $tmhOAuth = new tmhOAuth(array(
  9.   'consumer_key'    => 'CONSUMER_KEY',
  10.   'consumer_secret' => 'CONSUMER_SECRET',
  11.   'user_token'      => 'USER_TOKEN',
  12.   'user_secret'     => 'USER_SECRET',
  13. ));
  14.  
  15. $method = 'https://stream.twitter.com/1/statuses/filter.json';
  16. $params = array(
  17.   'follow' => 'xxxxxxxxx',
  18. );
  19. $tmhOAuth->streaming_request('POST', $method, $params, 'my_streaming_callback');
  20. tmhUtilities::pr($tmhOAuth);
  21. ?>

while using track instead of follow I got the resulted tweets. I got the empty tweets when using follow as parameter.

What's the problem here?

1 year 22 weeks ago
SelviKaruppanan
@SelviKaruppanan Selvi Karuppanan

I am using the URL https://stream.twitter.com/1/statuses/filter.json with the parameter 'follow' as 'AAAAAAAAA' for test.
$params = array(
'follow' => 'follower_id',
}
But it always returns empty string.
Is there any way to retrieve tweets?

1 year 22 weeks ago
SelviKaruppanan
@SelviKaruppanan Selvi Karuppanan

I can play streaming with track keyword but can't include follow id for the particular user.
I am using tmhOAuth with PHP..How to use follow id with streaming..
Is follow id is nothing but user id?
anyone there?

1 year 22 weeks ago
episod
@episod Taylor Singletary

I'm not sure I understand what the problem you're having is. When you pass a user ID to the follow parameter, it needs to be a numerical ID -- not the user's screen name. Once connected, your stream should persist for a long while -- you may not get much data back if there's no activity around the users you've indicating with the follow parameter.

1 year 22 weeks ago
SelviKaruppanan
@SelviKaruppanan Selvi Karuppanan

Thanks Taylor...
I have consumer_key,consumer_secret_key,user_token,user_secret keys.(This is my application keys)
I have followed Mr.X and Mr.X also followed me. Now i need to get the tweets of Mr.X. I have gave Mr.X's userid to follow parameter. Now here which tweets shall I receive?..Mr.X sent tweet to me...may I got these tweets?

1 year 22 weeks ago
SelviKaruppanan
@SelviKaruppanan Selvi Karuppanan

When using "follow" param in tmhOAuth streaming api it always shows the empty string as result. But there has tweets around that user.
In tmhOAuth.php file we have to change anything? (Eg. User agent)
I have changed consumer_key,consumer_secret_key,user_token,user_secret keys.(all my own test application keys).
Anyone worked out streaming with follow using tmhOAuth? Is it working?
Please give me the suggestion...Anything will be appreciated.

1 year 22 weeks ago
episod
@episod Taylor Singletary

Can you detail the steps you're following again? How are you measuring the tweets around a user?

We made a massive update to our Streaming API documentation yesterday -- I recommend taking a look and seeing if it can answer some of the questions you're having: The Streaming APIs

1 year 22 weeks ago
SelviKaruppanan
@SelviKaruppanan Selvi Karuppanan

I have gone through your updated Streaming api documentation. It's really very clear and informative.Now I move on to my problem..

I have followed Mr.X and Mr.X also followed me and Mr.Y. I have sent tweets to Mr.X and also Mr.X sent tweets to Mr.Y. Now I need to get the tweets of Mr.X(Tweets around the user is present becoz Mr.X sent tweets to Mr.Y).

For that I have gave Mr.X's userid in follow parameter. Also I have put all my keys like consumer_key,consumer_secret_key,user_token,user_secret keys(This is my application keys) for authentication. I am using statuses/filter.json POST method and setting the user agent as my test application(Eg: "Testapp (http://testapp.com/twit/)")...These are all about my coding. For this I have always received the empty string as result and the response code as 200. Do u know why this problem occurs?...May i know where am wrong? Any suggestions would be greatly appreciated. Thanks!!!

1 year 22 weeks ago
SelviKaruppanan
@SelviKaruppanan Selvi Karuppanan

Anyone?

1 year 21 weeks ago
SelviKaruppanan
@SelviKaruppanan Selvi Karuppanan

In tmhOAuth.php file user_agent variable is there na. Is that variable value is nothing but the owner of the consumer_key,consumer_secret_key,user_token,user_secret key's application name? Which value we have to assign for that variable?

1 year 22 weeks ago
SelviKaruppanan
@SelviKaruppanan Selvi Karuppanan

anyone there?

1 year 22 weeks ago
varunsankar8
@varunsankar8 varun sankaranarayan

https://github.com/themattharris/tmhOAuth/master/examples/streming.php

this url is not working can i get any other?

30 weeks 2 days ago
episod
@episod Taylor Singletary

The examples for that library moved to a different project, see: https://github.com/themattharris/tmhOAuth-examples/blob/master/streaming.php

30 weeks 1 day ago