NOTE: This doesn't set the "Authorization: " prefix, which is required.
It's not set because various set header functions prefer different
ways to do that.
public getHeaderString ( array $args = [] ) : string | ||
$args | array | |
return | string |
public function processData($data) { $data = array("data" => $data); $app_key = $this->app_key; $app_secret = $this->app_secret; $oauth = new OAuthSimple(); $result = $oauth->sign(array("path" => "http://beta.snowshoestamp.com/api/v2/stamp", "parameters" => $data, "action" => "POST", "signatures" => array("consumer_key" => $app_key, "shared_secret" => $app_secret))); $header = $oauth->getHeaderString(); $ch = curl_init($result['signed_url']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: " . $header)); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); $return = curl_exec($ch); $curlError = curl_error($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); return $return; }
private function getOAuthHeader($location, $request) { try { $oauth = new OAuthSimple($this->getAccountId(), $this->getSharedKey()); $oauth->setAction("POST"); $oauth->genBodyHash($request); $parse = parse_url($location); $port = (isset($parse["port"]) and ($parse["port"] == '80' or $parse["port"] == '443')) ? '' : !isset($parse["port"]) ? '' : ':' . $parse["port"]; if (!is_null($this->language)) { $oauth->setParameters(array('lang' => $this->language)); } $oauth->setPath($parse["scheme"] . '://' . $parse["host"] . $port . $parse["path"]); $header_string = $oauth->getHeaderString(); $oauth->reset(); } catch (Exception $e) { throw new TurnitinSDKException('oautherror', $e->getMessage(), $this->getLogPath()); } return $header_string; }