OAuthSimple::getHeaderString PHP Method

getHeaderString() public method

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 getHeaderString($args = array())
    {
        if (empty($this->_parameters['oauth_signature'])) {
            $this->sign($args);
        }
        $result = 'OAuth ';
        foreach ($this->_parameters as $pName => $pValue) {
            if (strpos($pName, 'oauth_') !== 0) {
                continue;
            }
            if (is_array($pValue)) {
                foreach ($pValue as $val) {
                    $result .= $pName . '="' . self::_oauthEscape($val) . '", ';
                }
            } else {
                $result .= $pName . '="' . self::_oauthEscape($pValue) . '", ';
            }
        }
        return preg_replace('/, $/', '', $result);
    }

Usage Example

 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;
 }
All Usage Examples Of OAuthSimple::getHeaderString