|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-04-04 10:02 UTC] djpate at gmail dot com
Description:
------------
Hello again,
I'm writing a code to integrate google calendar api and I struggled to modify an Event using their API to finally realize that the problem came from the automatic redirect.
Reproduce code:
---------------
//This should work but doesn't
$this->oauth->fetch("https://www.google.com/calendar/feeds/default/private/full",$event,OAUTH_HTTP_METHOD_POST,array("Content-Type"=>"application/json","GData-Version"=>"2"));
//The working fix
$this->oauth->disableRedirects();
$this->oauth->fetch("https://www.google.com/calendar/feeds/default/private/full",$event,OAUTH_HTTP_METHOD_POST,array("Content-Type"=>"application/json","GData-Version"=>"2"));
$info = $this->oauth->getLastResponseInfo();
if($info['http_code'] == 302){
$this->oauth->fetch($info['redirect_url'],$event,OAUTH_HTTP_METHOD_POST,array("Content-Type"=>"application/json","GData-Version"=>"2"));
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 23 14:00:01 2025 UTC |
I have had the same issue, and was going to submit a bug report. I noticed that my POST submissions, when redirected, were being changed to GET methods when following the redirect. After digging around for a long time, I found lines 1740- 1759 of OAuth.c in 1.1.0: ---------- if (soo->redirects >= OAUTH_MAX_REDIRS) { /*stuff*/ } else { ++soo->redirects; oauth_apply_url_redirect(&surl, soo- >last_location_header); smart_str_0(&surl); final_http_method = OAUTH_HTTP_METHOD_GET; } ---------- I'm not completely familiar with C or this code base, but it appears to me that the main suspect is line 1758, where it is setting the method to GET. In the context of the function, this appears that any time a redirect is followed, it defaults to GET. This is a problem for me since I have to use a workaround similar to what djpate posted.