PHP Classes

Proposal for a small improvement

Recommend this page to a friend!

      PHP OAuth Library  >  All threads  >  Proposal for a small improvement  >  (Un) Subscribe thread alerts  
Subject:Proposal for a small improvement
Summary:Post data is not always sent, I could patch that as indicated.
Messages:8
Author:E.F. de moor
Date:2013-11-29 07:16:25
Update:2014-01-12 10:16:30
 

  1. Proposal for a small improvement   Reply   Report abuse  
Picture of E.F. de moor E.F. de moor - 2013-11-29 07:16:25
Dear Manuel,

First of all I want to thank you for the oath_client_class, it is very useful.
Also I like the way the storage calls can be overridden, very useful.

I had a small problem with the SendApiRequest method, especially when using method a of "POST". The authorization data was not sent to the (dropbox) host.

Fortunately it was easy to solve in the source of auto_client.php:

Line 1303 reads:
$arguments['PostValues'] = $parameters;

If I replaced this by:
$arguments['PostValues'] = $post_values;

and all worked fine.

The following code can be used to reproduce the problem, it didn't work and with the above mentioned patch it did.

// $myClientId : Dropbox application client ID
// $myClientSecret: Secret code belonging to client ID
// $myRedirectUri: The URL Dropbox will refer back to after successfull approval
// $previousCursor: If any: the previous sync code Dropbox provided.

$client = new oauth_client_class();
$this->client_id = $myClientId;
$this->client_secret = $myClientSecret;
$this->redirect_uri = $myRedirectUri;
if($previousCursor)
$this->cursor = $previousCursor;
if(($success = $this->Initialize())) {
if(($success = $this->Process())) {
if($this->exit) {
echo "You are redirected to the Dropbox website for approval";
exit();
}
if(strlen($this->access_token))
{
$success = $this->CallAPI(
'https://api.dropbox.com/1/account/info',
'GET', array(), array('FailOnAccessError'=>true), $user
);
}
}
$success = $this->Finalize($success);
}
if(!$this->exit && $success) {
if($this->cursor)
$parms['cursor'] = $this->cursor;
$success = $this->CallAPI(
"https://api.dropbox.com/1/delta",
'POST',
$parms,
array('FailOnAccessError'=>true),
$delta
);
print_r($delta)
}
}



Regards and thanks again for all the work!

Ernst de Moor
The Netherlands.

  2. Re: Proposal for a small improvement   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-11-30 05:06:58 - In reply to message 1 from E.F. de moor
Sorry for the delay. Your case was not forgotten. It is that it requires that I spend time trying your use case and evaluate it carefully.

Right now I am busy with the launch of Composer support for installation of packages in PHPClasses. That should happen in the next days. Then I can get back to your case. Please be patient.

  3. Re: Proposal for a small improvement   Reply   Report abuse  
Picture of E.F. de moor E.F. de moor - 2013-12-03 08:50:01 - In reply to message 2 from Manuel Lemos
Dear Manuel,

No problem, thanks for your reaction!
Succes with Composer, and again thanks for all your work!

Ernst.

  4. Re: Proposal for a small improvement   Reply   Report abuse  
Picture of Sebastian B. Sebastian B. - 2013-12-16 22:03:51 - In reply to message 3 from E.F. de moor
The patch fixes a problem I had with POST (to XING API) containing parameters, thank you!

But it seems that the patch breaks parameter support for API requests using GET method. (I'm not 100% sure about this. I performed only a short test because my GET requests don't need parameters in my use case)

  5. Re: Proposal for a small improvement   Reply   Report abuse  
Picture of E.F. de moor E.F. de moor - 2013-12-17 07:08:00 - In reply to message 4 from Sebastian B.
Sebastian,

I use both POST and GET parameters for my implementation, and both work here. As the patch only replaces the PostValues variable, I hope they are unrelated?

Regards,

Ernst.

  6. Re: Proposal for a small improvement   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-12-20 19:26:25 - In reply to message 4 from Sebastian B.
This patch seems correct.

Can you give an example that is broken with GET requests?

Usually GET requests do not have request body, so the parameters should not be sent as form data. But I may be missing some edge case.

  7. Re: Proposal for a small improvement   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-01-12 10:06:58 - In reply to message 1 from E.F. de moor
I have applied your patch but I could not test it because it seems Dropbox with OAuth 1.0 is not working.

Anyway I added support for using Dropbox with OAuth 2.0. Just use Dropbox2 as server value.

  8. Re: Proposal for a small improvement   Reply   Report abuse  
Picture of E.F. de moor E.F. de moor - 2014-01-12 10:16:30 - In reply to message 7 from Manuel Lemos
Manuel,

Thanks a lot for applying the patch, and even more so for adding Dropbox2!
My dropbox connection with your patched source still works, so I will soon replace it with your new version, will let you know!

Regards,

Ernst de Moor.