I am implementing a signing service witch uses OAuth. For this service I have gotten a set of keys that will never expire and I can call it with GET without any problems. Now I need to send a POST request to the server with a JSON that I have tested in their testing suite that does work there. I am pasting the function (that is part of a class):
public function updatedoc($docid,$documentbody){
$url=$this->api_url."/api/v1/update/".$docid;
try {
$oauth = new OAuth($this->oauth_consumer_key,$this->oauth_signature,OAUTH_SIG_METHOD_PLAINTEXT,OAUTH_AUTH_TYPE_AUTHORIZATION);
$oauth->enableDebug();
$oauth->setAuthType(OAUTH_AUTH_TYPE_FORM);
$oauth->setToken($this->oauth_token,$this->oauth_token_secret);
echo $OA_header = $oauth->getRequestHeader("POST", $url);
$oauth->setAuthType(OAUTH_AUTH_TYPE_FORM);
$oauth->fetch($url,"json=".rawurlencode(json_encode($documentbody)), OAUTH_HTTP_METHOD_POST, array('Authorization'=>$OA_header));
echo $fileinfo = $oauth->getLastResponse();
}
catch(OAuthException $E) {
$fileinfo="false";print_r($E);
}
return $fileinfo;
}
I get that the JSON is not correct, but when I post it in their testing suite it is OK. Am I thinking anything here wrong?