PHP Classes

Unable to use CallAPI with Twitter

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  How to Implement PHP ...  >  All threads  >  Unable to use CallAPI with Twitter  >  (Un) Subscribe thread alerts  
Subject:Unable to use CallAPI with Twitter
Summary:Unable to send additional parameters using an array
Messages:8
Author:Olivier Zuccaro
Date:2014-10-13 15:10:34
 

  1. Unable to use CallAPI with Twitter   Reply   Report abuse  
Picture of Olivier Zuccaro Olivier Zuccaro - 2014-10-13 15:10:34
Hi Manuel,

Thanks for your great class.
But i've got an issue using it with Twitter.

Everything is running fine as long as i'm not sending any parameters (3rd param of the CallAPI method). But as soon as i try to send params, i always get "Could not authenticate you (32)".

For instance :
$datas = array('include_entities' => 'false', 'skip_status' => 'true');
$success = $client->CallAPI($url,$type, $datas, array('FailOnAccessError'=>false,'ConvertObjects'=>1),$user);

If i just pass an empty array, it works.

So needless to say that for any other api call besides basic authentication, i can't do any request to read specific twitter feeds or execute a search.

  2. Re: Unable to use CallAPI with Twitter   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-10-13 20:26:34 - In reply to message 1 from Olivier Zuccaro
I just tried the example scripts sending Twitter API calls with parameters and it works fine. Did you try the latest version submitted today?

If you still have problems, I need to have a concrete API call example that I can use to reproduce the problem.

  3. Re: Unable to use CallAPI with Twitter   Reply   Report abuse  
Picture of Olivier Zuccaro Olivier Zuccaro - 2014-10-14 07:32:41 - In reply to message 2 from Manuel Lemos
Allright,

Thanks for your fast answer, i'll update the build and if i still got the problem, i'll give you the code.

  4. Re: Unable to use CallAPI with Twitter   Reply   Report abuse  
Picture of Olivier Zuccaro Olivier Zuccaro - 2014-10-14 08:53:01 - In reply to message 2 from Manuel Lemos
Manuel,

So after the update, still the same issue.

Here is the code i used to test it out :
pastebin.com/4CzhYbra

I added a few comments to show you how I can make it work (using authorization_headers).

If i don't change the original value of authorization_headers on the object, the code returned is always "Could not authenticate you" (code 32).

I found that way back in the support forum... it was kinda hard since navigating through pages here is a pain in the a...

Anyway, if you have any ideas :)


  5. Re: Unable to use CallAPI with Twitter   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-10-15 04:44:03 - In reply to message 4 from Olivier Zuccaro
Oh, I see, you are passing the parameters in the array, rather than the URL for GET method.

I just fixed the class to make it pass the arguments to the URL when the method is not POST. Now it should work correctly. Just let me know otherwise.

  6. Re: Unable to use CallAPI with Twitter   Reply   Report abuse  
Picture of Olivier Zuccaro Olivier Zuccaro - 2014-10-15 07:53:09 - In reply to message 5 from Manuel Lemos
Yup, i thought every parameters had to be passed using this array

Thanks for the fix though ! It's great to see a fast and good support like that ;]

Anyway, i think that your fix has changed something on the request.
When i was waiting for your answer, i was implementing another api call for Facebook.

I was testing the request with this code : http://pastebin.com/fSBmB1an

Yesterday (around 7pm) it was working, i had the object listing all accounts.

This morning, i just accessed the url and i have this error :

- Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api
- GraphMethodException
- Code 100

  7. Re: Unable to use CallAPI with Twitter   Reply   Report abuse  
Picture of Olivier Zuccaro Olivier Zuccaro - 2014-10-15 07:55:59 - In reply to message 6 from Olivier Zuccaro
By the way, line 19 of the paste, there is still the Process method called. It was for test purposes.

With or without, the error is triggered anyway.

  8. Re: Unable to use CallAPI with Twitter   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-10-15 08:52:15 - In reply to message 6 from Olivier Zuccaro
No, the last fix only changed OAuth 1 code. Facebook only uses OAuth 2.

It seems you are calling the CallAPI function without checking if the access token was obtained. You can only call it after the access token is retrieved. See the example script.