I am using the Twitter API for OAuth.
I received a token operation to work without any problems using GET.
However, when I do the same thing using POST, I get the 'Failed to validate the Oath sign' error.
I'm using different curl options here:
curl_setopt ($ ch, CURLOPT_URL, ''. $ Url_post_str. ''); Curl_setopt ($ CH, CURLOPT_POST, 1); Curl_setopt ($ CH, CURLOPT_POSTFIELDS, $ post_vars_arr); Curl_setopt ($ CH, CURLOPT_HEADER, 0); Curl_setopt ($ CH, CURLOPT_FOLLOWLOCATION, 1); Curl_setopt ($ CH, CURLOPT_MAXREDIRS, 10); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, 1); Curl_setopt ($ ch, CURLOPT_HTTPHEADER, array ('expected:'));
Can you help?
Thank you
I thought it a while later
It is revealed that because I was using an array for the post field i.e.
curl_setopt ($ ch, CURLOPT_POSTFIELDS, ** $ post_vars_arr **) ;
The content type of the form was multiple / form-data, which is not supported by the Twitter OAuth API.
So pass this array to a query-string and the same curl_setopt i.e.
curl_setopt ($ ch, CURLOPT_POSTFIELDS, ** $ post_vars_str **);
I understand that when you use a query string instead of an array, the form content type will be application / x-www-form-urlencoded (Which is supported by the Twitter API) and not multipart / form-data .
And in the same way I got this job. I hope it helps someone else.
Comments
Post a Comment