See below what I use for the user_timeline which works fine. For the
mentions I only changed the second line to reflect that now menions
should be returned which gives me th e" Incorrect signature"
message...

$method="GET";
$resource='http://api.twitter.com/1/statuses/user_timeline.xml';
$oauth_signature_method="HMAC-SHA1";
$oauth_version="1.0";
$oauth_consumer_key="consumerkey";
$oauth_consumer_secret="consumersecret";
$oauth_token="oauthtoken";
$oauth_token_secret="oauthtokensecret";
$oauth_nonce=get_nonce();
$oauth_timestamp=time();

$base="oauth_consumer_key"."=".$oauth_consumer_key;
$base .="&"."oauth_nonce"."=".$oauth_nonce;
$base .="&"."oauth_signature_method"."=".$oauth_signature_method;
$base .="&"."oauth_timestamp"."=".$oauth_timestamp;
$base .="&"."oauth_token"."=".$oauth_token;
$base .="&"."oauth_version"."=".$oauth_version;
$base=$method."&".rawurlencode($resource)."&".rawurlencode($base);

$key=$oauth_consumer_secret."&".$oauth_token_secret;
$oauth_signature=get_oauth_signature($base,$key);

$header='Authorization: OAuth realm="'.$resource.'"';
$header .=', oauth_nonce="'.$oauth_nonce.'"';
$header .=', oauth_signature_method="'.$oauth_signature_method.'"';
$header .=', oauth_timestamp="'.$oauth_timestamp.'"';
$header .=', oauth_consumer_key="'.$oauth_consumer_key.'"';
$header .=', oauth_token="'.$oauth_token.'"';
$header .=', oauth_signature="'.$oauth_signature.'"';
$header .=', oauth_version="'.$oauth_version.'"';

$_h = array('Expect:');
$_h[] = substr($header, 0);
$resource .='?count=200&page='.$page.'&include_rts=true';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $resource);
curl_setopt($curl, CURLOPT_POST, false);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $_h);
$result = curl_exec($curl);
curl_close($curl);

On Apr 12, 3:48 pm, Taylor Singletary <taylorsinglet...@twitter.com>
wrote:
> Can you give an example of the HTTP headers or OAuth query parameters you're
> sending along with both variations of the request? While it's not required,
> I recommend explicitly specifying a user_id or screen_name for these
> methods, instead of relying on the magic implicit user that auth brings you.
> I also recommend sticking to HTTP header-based auth, as it dramatically
> separates concerns.
>
> Your resource-specific query parameters should be added to the URL before
> you compute your signature -- in your signature base string, the query
> parameters should be sorted.
>
> Thanks,
> Taylor
>
> @episod <http://twitter.com/episod> - Taylor Singletary
>
> On Tue, Apr 12, 2011 at 5:13 AM, Randomness <randomness.bl...@gmail.com>wrote:
>
>
>
> > I wrote some code that retrieves tweets sent by an authenticated user
> > which works fine. As the resource I use:
>
> >http://api.twitter.com/1/statuses/user_timeline.xml
>
> > which is used for te base string. For the CURLOPT_URL I added paramers
> > to the URL like:
>
> > ?count=200&page=1&include_rts=true
>
> > From the documentation I figured that retrieving mentions works
> > exactly the same, only the resource needs to be changed to:
>
> >http://api.twitter.com/1/statuses/mentions.xml
>
> > This is the only change I made to the code, all else remains exactly
> > the same. Instead of retrieving my mentions I get the message
> > "Incorrect signature".
>
> > I have been staring at my code for a while now, and don't see what is
> > wrong.
>
> > Anyone any suggestions or an explanation?
>
> > --
> > Twitter developer documentation and resources:http://dev.twitter.com/doc
> > API updates via Twitter:http://twitter.com/twitterapi
> > Issues/Enhancements Tracker:
> >http://code.google.com/p/twitter-api/issues/list
> > Change your membership to this group:
> >http://groups.google.com/group/twitter-development-talk- Hide quoted text -
>
> - Show quoted text -

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk

Reply via email to