reset() public method

Reset the parameters and URL
public reset ( ) : OAuthSimple
return OAuthSimple
Esempio n. 1
0
        $options[CURLOPT_SSLKEYPASSWD] = '1234';
        $options[CURLOPT_SSLKEY] = BASE_PATH . '/certs/entrust-private.pem';
        $signatures = array('consumer_key' => 'MWSAN8S5AAFPMMNBV3DQIEWH4TM9FE', 'shared_secret' => 's', 'rsa_private_key' => BASE_PATH . '/certs/rq-partner-app-2-privatekey.pem', 'rsa_public_key' => BASE_PATH . '/certs/rq-partner-app-2-publickey.cer');
        $xro_settings = $xro_partner_mac_defaults;
        break;
}
// bypass if we have an active session
session_start();
if ($_SESSION && $_REQUEST['start'] == 1) {
    $signatures['oauth_token'] = $_SESSION['access_token'];
    $signatures['oauth_secret'] = $_SESSION['access_token_secret'];
    $signatures['oauth_session_handle'] = $_SESSION['oauth_session_handle'];
    //////////////////////////////////////////////////////////////////////
    if (!empty($_REQUEST['endpoint'])) {
        // Example Xero API Access:
        $oauthObject->reset();
        $result = $oauthObject->sign(array('path' => $xro_settings['xero_url'] . '/' . $_REQUEST['endpoint'] . '/', 'parameters' => array('oauth_signature_method' => $xro_settings['signature_method']), 'signatures' => $signatures));
        $ch = curl_init();
        curl_setopt_array($ch, $options);
        curl_setopt($ch, CURLOPT_URL, $result['signed_url']);
        $r = curl_exec($ch);
        curl_close($ch);
        parse_str($r, $returned_items);
        $oauth_problem = $returned_items['oauth_problem'];
        if ($oauth_problem) {
            session_destroy();
        }
        echo 'CURL RESULT: <textarea cols="160" rows="40">' . $r . '</textarea><br/>';
    }
    // Example Xero API AccessToken swap:
    if (!empty($_REQUEST['action'])) {
 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;
 }
Esempio n. 3
0
   $accessToken
   $tokenSecret
*/
// Some sample argument values
// You can pass in arguments either as a string of URL characters:
$argumentsAsString = "term=mac%20and+me&expand=formats,synopsis&max_results=1";
//   or a hash:
$argumentsAsObject = array('term' => 'the prisoner', 'expand' => 'formats,synopsis', 'max_results' => '1', 'v' => '2.0', 'output' => 'json');
$path = "http://api.netflix.com/catalog/titles";
# Test 1 ====
$oauth = new OAuthSimple($apiKey, $sharedSecret);
$oauth->setParameters($argumentsAsString);
$oauth->setPath($path);
$sample1Results = $oauth->sign();
# Test 2 =====
$oauth->reset();
$sample2Results = $oauth->sign(array('action' => 'GET', 'path' => $path, 'parameters' => $argumentsAsObject));
# Test 3 ======
$oauth = new OAuthSimple();
$sample3Results = $oauth->sign(array('path' => 'http://api.netflix.com/catalog/people', 'parameters' => array('term' => 'Harrison Ford', 'max_results' => '5'), 'signatures' => array('consumer_key' => $apiKey, 'shared_secret' => $sharedSecret, 'access_token' => $accessToken, 'access_secret' => $tokenSecret)));
?>
<html>
    <head>
        <title>Test Document</title>
    </head>
    <body>
        <h1>Test Document</h1>
        <ol>
            <li><a href="<?php 
print $sample1Results['signed_url'];
?>