OAuthSimple::setParameters PHP Method

setParameters() public method

Set the parameters either from a hash or a string
public setParameters ( string | array | object $parameters = [] ) : OAuthSimple
$parameters string | array | object List of parameters for the call, this can either be a URI string (e.g. "foo=bar&gorp=banana" or an object/hash)
return OAuthSimple
    public function setParameters($parameters = array())
    {
        if (is_string($parameters)) {
            $parameters = $this->_parseParameterString($parameters);
        }
        if (empty($this->_parameters)) {
            $this->_parameters = $parameters;
        } else {
            if (!empty($parameters)) {
                $this->_parameters = array_merge($this->_parameters, $parameters);
            }
        }
        if (empty($this->_parameters['oauth_nonce'])) {
            $this->_getNonce();
        }
        if (empty($this->_parameters['oauth_timestamp'])) {
            $this->_getTimeStamp();
        }
        if (empty($this->_parameters['oauth_consumer_key'])) {
            $this->_getApiKey();
        }
        if (empty($this->_parameters['oauth_token'])) {
            $this->_getAccessToken();
        }
        if (empty($this->_parameters['oauth_signature_method'])) {
            $this->setSignatureMethod();
        }
        if (empty($this->_parameters['oauth_version'])) {
            $this->_parameters['oauth_version'] = "1.0";
        }
        return $this;
    }

Usage Example

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