Hello!

I found out what the problem was. The

$oauth->fetch($url)

needed to specify it was a GET call like:

$oauth->fetch($url, null, OAUTH_HTTP_METHOD_GET,
array('Connection'=>'close'));

It works without those parameters for some versions of PHP+Pecl-Oauth and
not for other :)

Thanks a lot for all your help & suggestions,
@themattharris<https://twitter.com/intent/follow?screen_name=themattharris>.





On Fri, Jun 24, 2011 at 7:37 PM, Matt Harris <thematthar...@twitter.com>wrote:

> Hi Sreejata,
>
> Thanks for providing this information. Are you able to find out what the
> server is actually sending to the Twitter API. The code you've provided
> shows where the error is happening but not what information is being sent to
> the API.
>
> Without knowing what is being sent by your code it is hard to suggest
> possible causes for the problem.
> Do you know which OAuth library are you using?
>
> Best,
> @themattharris<https://twitter.com/intent/follow?screen_name=themattharris>
> Developer Advocate, Twitter
>
>
>
>
> On Fri, Jun 24, 2011 at 5:51 AM, Sreejata Chatterjee 
> <gundad...@gmail.com>wrote:
>
>> Matt! Thank you SO much for the reply... I will try and explain what else
>> I found out. A test example is:
>>
>>
>> <?php
>>
>>     define( "CONSUMER_KEY","*********" );
>>     define( "CONSUMER_SECRET", "****************" );
>>
>>     $oauth = new
>> OAuth(CONSUMER_KEY,CONSUMER_SECRET,OAUTH_SIG_METHOD_HMACSHA1);
>>     $access_token = file_get_contents("access_token");
>>     $access_token_secret = file_get_contents("access_token_secret");
>>     $oauth->setToken($access_token, $access_token_secret);
>>
>>     $url = "http://api.twitter.com/1/statuses/home_timeline.xml";;
>>
>>     $oauth->fetch($url);
>>     $json = json_decode($oauth->getLastResponse(),true);
>>     print_r($json);
>>
>> ?>
>>
>> Now, I tried this script and the same user (@Research4SML) from 3
>> different servers. The results are:
>>
>> CentOS, PHP 5.2.17, and Ubuntu, PHP 5.3.2:
>>
>>> PHP Fatal error:  Uncaught exception 'OAuthException' with message
>>> 'Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect)'
>>> in /var/www/vhosts/default/iresearch/Scholar/oauth/test.php:14
>>> Stack trace:
>>> #0 /var/www/vhosts/default/iresearch/Scholar/oauth/test.php(14):
>>> OAuth->fetch('http://api.twit...')
>>> #1 {main}
>>>   thrown in /var/www/vhosts/default/iresearch/Scholar/oauth/test.php on
>>> line 14
>>>
>>>
>>
>> From another CentOS machine, PHP 5.2.10, IT WORKS! (Of course I had to
>> generate new tokens for every server).
>> I did the "curl http://api.twitter.com/1/account/rate_limit_status.xml";
>> call from all the servers and there is no rate limiting affecting the
>> results. I need it to work from the CentOS, PHP 5.2.17 machine.
>>
>> What might be the reason behind this behavior and how can I fix it?
>>
>>
>>
>> On Thu, Jun 23, 2011 at 6:06 PM, Matt Harris 
>> <thematthar...@twitter.com>wrote:
>>
>>> Hi,
>>>
>>> A 400 error indicates something in the request you are making is
>>> malformed. Are you using a library to make requests or did you create your
>>> own wrapper?
>>>
>>> If you created your own library for making requests you may instead want
>>> to try one of the libraries listed on our developer resources site:
>>>     http://dev.twitter.com/pages/libraries
>>>
>>> Moving forward, to help identify the cause of the 400 could you share the
>>> the request header and URL you are sending and the API headers and response
>>> body returned. Remember to remove any OAuth secrets from the code you share.
>>>
>>> Best
>>> @themattharris<https://twitter.com/intent/follow?screen_name=themattharris>
>>> Developer Advocate, Twitter
>>>
>>>
>>>
>>>
>>> On Mon, Jun 20, 2011 at 12:39 PM, antiphobe <gundad...@gmail.com> wrote:
>>>
>>>> The time was in sync and I still used ntpd to reset it. No use.
>>>>
>>>> I tried to use the same script on different server, same user -> 400
>>>> error (bad request)
>>>> Tried on new server, different user, same script -> it works!
>>>>
>>>> So I'm lead to believe something might be wrong with the twitter user
>>>> a/c? Is that known to happen?
>>>>
>>>> --
>>>> Twitter developer documentation and resources:
>>>> https://dev.twitter.com/doc
>>>> API updates via Twitter: https://twitter.com/twitterapi
>>>> Issues/Enhancements Tracker:
>>>> https://code.google.com/p/twitter-api/issues/list
>>>> Change your membership to this group:
>>>> https://groups.google.com/forum/#!forum/twitter-development-talk
>>>>
>>>
>>>  --
>>> Twitter developer documentation and resources:
>>> https://dev.twitter.com/doc
>>> API updates via Twitter: https://twitter.com/twitterapi
>>> Issues/Enhancements Tracker:
>>> https://code.google.com/p/twitter-api/issues/list
>>> Change your membership to this group:
>>> https://groups.google.com/forum/#!forum/twitter-development-talk
>>>
>>
>>
>>
>> --
>> Sreejata
>> ~~~~~~~~~~
>> MagicLamp Software Solutions Inc.
>> Halifax, Nova Scotia
>> 902-482-7103, 902-448-6357
>> http://www.magiclampsoft.com
>>
>>  --
>> Twitter developer documentation and resources:
>> https://dev.twitter.com/doc
>> API updates via Twitter: https://twitter.com/twitterapi
>> Issues/Enhancements Tracker:
>> https://code.google.com/p/twitter-api/issues/list
>> Change your membership to this group:
>> https://groups.google.com/forum/#!forum/twitter-development-talk
>>
>
>  --
> Twitter developer documentation and resources: https://dev.twitter.com/doc
> API updates via Twitter: https://twitter.com/twitterapi
> Issues/Enhancements Tracker:
> https://code.google.com/p/twitter-api/issues/list
> Change your membership to this group:
> https://groups.google.com/forum/#!forum/twitter-development-talk
>



-- 
Sreejata
~~~~~~~~~~
MagicLamp Software Solutions Inc.
Halifax, Nova Scotia
902-482-7103, 902-448-6357
http://www.magiclampsoft.com

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

Reply via email to