[twitter-dev] Re: streaming API help (regular API works)

2010-08-09 Thread Tom
You can't re-use signatures. Signatures use a nonce which is unique, a
timestamp that will invalidate the request after about 5 minutes, and
a signature that is based on the request you do (including URL).

Tom


On Aug 9, 4:22 am, ianrose ianros...@gmail.com wrote:
 Hi -

 I hope I am not posting a question that has previously been answered -
 I tried searching the archives but to no avail.

 I am trying to get the 'sample' stream API working but am getting 401
 Unathorized errors.  For debugging purposes, I am using curl for now.
 The following command fails (401):

 curl 'http://stream.twitter.com/1/statuses/sample.json?
 delimited=length' -H 'Authorization: OAuth realm=Twitter API,
 oauth_nonce=24599946, oauth_timestamp=1281319798,
 oauth_consumer_key=, oauth_signature_method=HMAC-SHA1,
 oauth_version=1.0, oauth_token=175905996-
 JkrGAl8ZXCgIjeZl3o7fMCD8HbyfVeDbkP9Y13mX, oauth_signature=i
 %2BVzWX23sp5t8%2Fz0swJl%2FDHloOo%3D'

 However, I believe that my OAuth stuff is (hopefully) correct because
 the following command works, where I have reused the exact same OAuth
 header (all I changed was the URL):

 curl 'http://api.twitter.com/1/statuses/user_timeline.json'-H
 'Authorization: OAuth realm=Twitter API, oauth_nonce=24599946,
 oauth_timestamp=1281319798, oauth_consumer_key=,
 oauth_signature_method=HMAC-SHA1, oauth_version=1.0,
 oauth_token=175905996-JkrGAl8ZXCgIjeZl3o7fMCD8HbyfVeDbkP9Y13mX,
 oauth_signature=i%2BVzWX23sp5t8%2Fz0swJl%2FDHloOo%3D'

 So what does this mean?  Are the authentication requirements at all
 different for these two API calls?  In case its relevant, note that I
 am using my account's single access token to create these OAuth
 signatures as opposed to a real customer key/secret pair.  Any
 suggestions on what else I can do to try and debug this?

 Many thanks!
 - Ian


[twitter-dev] Re: Streaming API Help

2009-09-19 Thread John Kalucki

I'd suggest trying to get this to work with curl first. Then, see what
the differences are in your implementation.

-John Kalucki
http://twitter.com/jkalucki
Services, Twitter Inc.

On Sep 19, 7:31 am, Greg gregory.av...@gmail.com wrote:
 I'm trying to implement Streaming API on my Twitter application to
 enhance the stabilty instead of using the Search API.

 Basically - I'm trying to use the track paramter to track a keyword.
 However, when I run this code - it just times out - nothing occurs.
 Perhaps I'm not using the track parameter correctly?

 I know I'm just dumping the code right now - but it was merely for
 test.

 My ad-hoc code is below:

 // twitter_stream.php
 ?
 $fp = fopen(http://username:passw...@stream.twitter.com/1/statuses/
 filter.json?track=ttl,wine, r);
 while($data = fgets($fp))
 {
     $new_data = json_decode($data);

         foreach($status as $new_data)
         {
                 var_dump($status);
                 echo hr;
         }}

 ?

 Thanks for the help!

 Greg


[twitter-dev] Re: Streaming API Help

2009-09-19 Thread Jim Gilliam
I ran into the same problem trying to do this in Ruby last night using this
technique: http://www.robares.com/2009/07/14/streaming-twitter-api.html

I think it's because /statuses/filter.json requires a POST, which isn't
supported by yajl-ruby.  So I'm stuck.  It works fine if you use one of the
other GET methods like /statuses/sample.json.

Jim Gilliam
http://act.ly/
http://twitter.com/jgilliam

On Sat, Sep 19, 2009 at 7:31 AM, Greg gregory.av...@gmail.com wrote:


 I'm trying to implement Streaming API on my Twitter application to
 enhance the stabilty instead of using the Search API.

 Basically - I'm trying to use the track paramter to track a keyword.
 However, when I run this code - it just times out - nothing occurs.
 Perhaps I'm not using the track parameter correctly?

 I know I'm just dumping the code right now - but it was merely for
 test.

 My ad-hoc code is below:

 // twitter_stream.php
 ?
 $fp = fopen(http://username:passw...@stream.twitter.com/1/statuses/
 filter.json?track=ttl,winehttp://username:passw...@stream.twitter.com/1/statuses/%0Afilter.json?track=ttl,wine,
 r);
 while($data = fgets($fp))
 {
$new_data = json_decode($data);

foreach($status as $new_data)
{
var_dump($status);
echo hr;
}
 }
 ?

 Thanks for the help!

 Greg



[twitter-dev] Re: Streaming API Help

2009-09-19 Thread Joseph Cheek

curl buffers, even when called with -N.  You won't get satisfactory
results with curl unless you get a lot of data.  Use wget instead.

Joseph Cheek
jos...@cheek.com, www.cheek.com
twitter: http://twitter.com/cheekdotcom


John Kalucki wrote:
 I'd suggest trying to get this to work with curl first. Then, see what
 the differences are in your implementation.

 -John Kalucki
 http://twitter.com/jkalucki
 Services, Twitter Inc.

 On Sep 19, 7:31 am, Greg gregory.av...@gmail.com wrote:
   
 I'm trying to implement Streaming API on my Twitter application to
 enhance the stabilty instead of using the Search API.

 Basically - I'm trying to use the track paramter to track a keyword.
 However, when I run this code - it just times out - nothing occurs.
 Perhaps I'm not using the track parameter correctly?

 I know I'm just dumping the code right now - but it was merely for
 test.

 My ad-hoc code is below:

 // twitter_stream.php
 ?
 $fp = fopen(http://username:passw...@stream.twitter.com/1/statuses/
 filter.json?track=ttl,wine, r);
 while($data = fgets($fp))
 {
 $new_data = json_decode($data);

 foreach($status as $new_data)
 {
 var_dump($status);
 echo hr;
 }}

 ?

 Thanks for the help!

 Greg


[twitter-dev] Re: Streaming API Help

2009-09-19 Thread Joseph Cheek

You also need a keep-alive of greater than 30 seconds.  And by default
PHP funtions timeout after 30 seconds, so you'll need to change that to
keep the script running indefinitely.

Joseph Cheek
jos...@cheek.com, www.cheek.com
twitter: http://twitter.com/cheekdotcom


Jim Gilliam wrote:
 I ran into the same problem trying to do this in Ruby last night using
 this technique:
 http://www.robares.com/2009/07/14/streaming-twitter-api.html

 I think it's because /statuses/filter.json requires a POST, which
 isn't supported by yajl-ruby.  So I'm stuck.  It works fine if you use
 one of the other GET methods like /statuses/sample.json. 

 Jim Gilliam
 http://act.ly/
 http://twitter.com/jgilliam

 On Sat, Sep 19, 2009 at 7:31 AM, Greg gregory.av...@gmail.com
 mailto:gregory.av...@gmail.com wrote:


 I'm trying to implement Streaming API on my Twitter application to
 enhance the stabilty instead of using the Search API.

 Basically - I'm trying to use the track paramter to track a keyword.
 However, when I run this code - it just times out - nothing occurs.
 Perhaps I'm not using the track parameter correctly?

 I know I'm just dumping the code right now - but it was merely for
 test.

 My ad-hoc code is below:

 // twitter_stream.php
 ?
 $fp = fopen(http://username:passw...@stream.twitter.com/1/statuses/
 filter.json?track=ttl,wine
 
 http://username:passw...@stream.twitter.com/1/statuses/%0Afilter.json?track=ttl,wine,
 r);
 while($data = fgets($fp))
 {
$new_data = json_decode($data);

foreach($status as $new_data)
{
var_dump($status);
echo hr;
}
 }
 ?

 Thanks for the help!

 Greg




[twitter-dev] Re: Streaming API Help

2009-09-19 Thread Chad Etzel

Hi Greg,

A couple of questions:

Are you running this is a browser? It will be much easier to test if
you can run the script from a console instead. There are all sorts of
output buffering issues to deal with in a browser.

Even if you are receiving any data from the stream, the way your code
is setup you won't ever see it:

   $new_data = json_decode($data);

   foreach($status as $new_data)
   {
   var_dump($status);
   echo hr;
   }

Your foreach syntax is reversed, perhaps? The $new_data variable will
be blank, but even worse since $status isn't set, the foreach loop
won't run.

Instead you should try something like:
$new_data = json_decode($data);
echo $data;
var_dump($new_data
echo hr;

That way at least you can determine if you are getting any data from
the stream at all.

-Chad

On Sat, Sep 19, 2009 at 10:31 AM, Greg gregory.av...@gmail.com wrote:

 I'm trying to implement Streaming API on my Twitter application to
 enhance the stabilty instead of using the Search API.

 Basically - I'm trying to use the track paramter to track a keyword.
 However, when I run this code - it just times out - nothing occurs.
 Perhaps I'm not using the track parameter correctly?

 I know I'm just dumping the code right now - but it was merely for
 test.

 My ad-hoc code is below:

 // twitter_stream.php
 ?
 $fp = fopen(http://username:passw...@stream.twitter.com/1/statuses/
 filter.json?track=ttl,wine, r);
 while($data = fgets($fp))
 {
    $new_data = json_decode($data);

        foreach($status as $new_data)
        {
                var_dump($status);
                echo hr;
        }
 }
 ?

 Thanks for the help!

 Greg


[twitter-dev] Re: Streaming API Help

2009-09-19 Thread Joel Strellner
Greg,

Please see the following code for a working example fo how to do the
Streaming API in PHP.  Not sure if it is the best way to do it, but it works
for us, and we use the Streaming API for a lot of data.

http://groups.google.com/group/twitter-development-talk/msg/761eb0b23872d430?hl=en

If you have any questions, please let me know.

-Joel

On Sat, Sep 19, 2009 at 11:48 AM, Chad Etzel jazzyc...@gmail.com wrote:


 Hi Greg,

 A couple of questions:

 Are you running this is a browser? It will be much easier to test if
 you can run the script from a console instead. There are all sorts of
 output buffering issues to deal with in a browser.

 Even if you are receiving any data from the stream, the way your code
 is setup you won't ever see it:

   $new_data = json_decode($data);

   foreach($status as $new_data)
   {
   var_dump($status);
   echo hr;
   }

 Your foreach syntax is reversed, perhaps? The $new_data variable will
 be blank, but even worse since $status isn't set, the foreach loop
 won't run.

 Instead you should try something like:
 $new_data = json_decode($data);
 echo $data;
 var_dump($new_data
 echo hr;

 That way at least you can determine if you are getting any data from
 the stream at all.

 -Chad

 On Sat, Sep 19, 2009 at 10:31 AM, Greg gregory.av...@gmail.com wrote:
 
  I'm trying to implement Streaming API on my Twitter application to
  enhance the stabilty instead of using the Search API.
 
  Basically - I'm trying to use the track paramter to track a keyword.
  However, when I run this code - it just times out - nothing occurs.
  Perhaps I'm not using the track parameter correctly?
 
  I know I'm just dumping the code right now - but it was merely for
  test.
 
  My ad-hoc code is below:
 
  // twitter_stream.php
  ?
  $fp = fopen(http://username:passw...@stream.twitter.com/1/statuses/
  filter.json?track=ttl,wine, r);
  while($data = fgets($fp))
  {
 $new_data = json_decode($data);
 
 foreach($status as $new_data)
 {
 var_dump($status);
 echo hr;
 }
  }
  ?
 
  Thanks for the help!
 
  Greg



[twitter-dev] Re: Streaming API Help

2009-09-14 Thread Rolando Espinoza La Fuente

On Mon, Sep 14, 2009 at 3:10 PM, Greg gregory.av...@gmail.com wrote:

 I've recently been given access to Streaming API - and I was given
 access to the gardenhose - however it is not listed on the Streaming
 API Documentation Website (http://apiwiki.twitter.com/Streaming-API-
 Documentation). Is anyone aware of the documentation for this API
 call?

http://stream.twitter.com/gardenhose.json

I'm not sure, but i think that was the early version of the api, but
still works.

 I am specifically looking to use it to get tweets with certain text in
 them - however should I be using the status/filter API? (http://
 apiwiki.twitter.com/Streaming-API-Documentation#statuses/filter)

I think you should try filter api with track parameter

$ curl http://stream.twitter.com/1/statuses/filter.json -uUser:Pass
-d track=twitter

Regards,

-- 
ø Rolando Espinoza La fuente


[twitter-dev] Re: Streaming API Help

2009-09-14 Thread John Kalucki

Greg,

All users can access the streaming API at default access levels. Roles
can give elevated access through the same URLs -- more statuses, more
keywords, etc.

Gardenhose access is additional access on the /1/statuses/
sample.format resource.

You should use the track keyword on the /1/statuses/filter.format
resource. If the default access level is insufficient, we can discuss
upgrading your access to restricted track. Most apps can run fine
without elevated access.

You should not use /gardenhose.format resource. It works via backward
compatibility mode and will go away shortly.

-John Kalucki
http://twitter.com/jkalucki
Services, Twitter Inc.


On Sep 14, 12:10 pm, Greg gregory.av...@gmail.com wrote:
 I've recently been given access to Streaming API - and I was given
 access to the gardenhose - however it is not listed on the Streaming
 API Documentation Website (http://apiwiki.twitter.com/Streaming-API-
 Documentation). Is anyone aware of the documentation for this API
 call?

 I am specifically looking to use it to get tweets with certain text in
 them - however should I be using the status/filter API? (http://
 apiwiki.twitter.com/Streaming-API-Documentation#statuses/filter)

 Any help on examples of these two APIs (PHP) would be helpful.

 Thanks,
 Greg