OAuthSimple::setAction PHP Method

setAction() public method

Set the "action" for the url, (e.g. GET,POST, DELETE, etc.)
public setAction ( string $action ) : OAuthSimple
$action string HTTP Action word.
return OAuthSimple
    public function setAction($action)
    {
        if (empty($action)) {
            $action = 'GET';
        }
        $action = strtoupper($action);
        if (preg_match('/[^A-Z]/', $action)) {
            throw new OAuthSimpleException('Invalid action specified for OAuthSimple.setAction');
        }
        $this->_action = $action;
        return $this;
    }

Usage Example

コード例 #1
0
 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;
 }