当前位置: 首页>>代码示例>>PHP>>正文


PHP OAuthRequest::from_consumer_and_token方法代码示例

本文整理汇总了PHP中OAuthRequest::from_consumer_and_token方法的典型用法代码示例。如果您正苦于以下问题:PHP OAuthRequest::from_consumer_and_token方法的具体用法?PHP OAuthRequest::from_consumer_and_token怎么用?PHP OAuthRequest::from_consumer_and_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OAuthRequest的用法示例。


在下文中一共展示了OAuthRequest::from_consumer_and_token方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: twolegged

/**
 * Uses two-legged OAuth to respond to a Google documents list API request
 * @param string $base_feed Full URL of the resource to access
 * @param array $params (optional) parameters to be added to url line
 * @param string $type The HTTP method (GET, POST, PUT, DELETE)
 * @param string $postData (optional) POST/PUT request body
 * @param string $version (optional) if not sent will be set to 3.0
 * @param string $content_type (optional) what kind of content is being sent
 * @param string $slug (optional) used in determining the revision of a document
 * @param boolean $batch is this a batch transmission?
 * @return string $response body from the server
 */
function twolegged($base_feed, $params, $type, $postdata = null, $version = null, $content_type = null, $slug = null, $batch = null)
{
    global $CFG;
    require_once $CFG->dirroot . '/repository/morsle/lib.php';
    // for morsle_decode
    require_once $CFG->dirroot . '/google/oauth.php';
    // Establish an OAuth consumer based on our admin 'credentials'
    if (!($CONSUMER_KEY = get_config('morsle', 'consumer_key'))) {
        return NULL;
    }
    if (!($CONSUMER_SECRET = get_config('morsle', 'oauthsecretstr'))) {
        return NULL;
    }
    $CONSUMER_SECRET = morsle_decode($CONSUMER_SECRET);
    $consumer = new OAuthConsumer($CONSUMER_KEY, $CONSUMER_SECRET, NULL);
    // Create an Atom entry
    $contactAtom = new DOMDocument();
    //    $contactAtom = null;
    $request = OAuthRequest::from_consumer_and_token($consumer, NULL, $type, $base_feed, $params);
    // Sign the constructed OAuth request using HMAC-SHA1
    $request->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, NULL);
    //  scope=https://docs.google.com/feeds/%20http://spreadsheets.google.com/feeds/%20https://docs.googleusercontent.com/
    // Make signed OAuth request to the Contacts API server
    if (!is_null($params)) {
        $url = $base_feed . '?' . implode_assoc('=', '&', $params);
    } else {
        $url = $base_feed;
    }
    $header_request = $request->to_header();
    $response = send_request($request->get_normalized_http_method(), $url, $header_request, $contactAtom, $postdata, $version, $content_type, $slug, $batch);
    return $response;
}
开发者ID:bobpuffer,项目名称:morsle-google,代码行数:44,代码来源:gauth.php

示例2: sendOAuthBodyPOST

function sendOAuthBodyPOST($method, $endpoint, $oauth_consumer_key, $oauth_consumer_secret, $content_type, $body)
{
    $hash = base64_encode(sha1($body, TRUE));
    $parms = array('oauth_body_hash' => $hash);
    $test_token = '';
    $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
    $test_consumer = new OAuthConsumer($oauth_consumer_key, $oauth_consumer_secret, NULL);
    $acc_req = OAuthRequest::from_consumer_and_token($test_consumer, $test_token, $method, $endpoint, $parms);
    $acc_req->sign_request($hmac_method, $test_consumer, $test_token);
    // Pass this back up "out of band" for debugging
    global $LastOAuthBodyBaseString;
    $LastOAuthBodyBaseString = $acc_req->get_signature_base_string();
    // echo($LastOAuthBodyBaseString."\m");
    $header = $acc_req->to_header();
    $header = $header . "\r\nContent-type: " . $content_type . "\r\n";
    $params = array('http' => array('method' => 'POST', 'content' => $body, 'header' => $header));
    try {
        $ctx = stream_context_create($params);
        $fp = @fopen($endpoint, 'rb', false, $ctx);
    } catch (Exception $e) {
        $fp = false;
    }
    if ($fp) {
        $response = @stream_get_contents($fp);
    } else {
        // Try CURL
        $headers = explode("\r\n", $header);
        $response = sendXmlOverPost($endpoint, $body, $headers);
    }
    if ($response === false) {
        throw new Exception("Problem reading data from {$endpoint}, {$php_errormsg}");
    }
    return $response;
}
开发者ID:ramanuv,项目名称:kennethware-2.0,代码行数:34,代码来源:OAuthBody.php

示例3: request

/**
 * Makes a request to the Yelp API and returns the response
 *
 * @param    $host    The domain host of the API
 * @param    $path    The path of the APi after the domain
 * @return   The JSON response from the request
 */
function request($host, $path) {
    $unsigned_url = "http://" . $host . $path;

    // Token object built using the OAuth library
    $token = new OAuthToken($GLOBALS['TOKEN'], $GLOBALS['TOKEN_SECRET']);

    // Consumer object built using the OAuth library
    $consumer = new OAuthConsumer($GLOBALS['CONSUMER_KEY'], $GLOBALS['CONSUMER_SECRET']);

    // Yelp uses HMAC SHA1 encoding
    $signature_method = new OAuthSignatureMethod_HMAC_SHA1();

    $oauthrequest = OAuthRequest::from_consumer_and_token(
        $consumer,
        $token,
        'GET',
        $unsigned_url
    );

    // Sign the request
    $oauthrequest->sign_request($signature_method, $consumer, $token);

    // Get the signed URL
    $signed_url = $oauthrequest->to_url();

    // Send Yelp API Call
    $ch = curl_init($signed_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $data = curl_exec($ch);
    curl_close($ch);

    return $data;
}
开发者ID:supermanrising,项目名称:virtual-photo-walks,代码行数:41,代码来源:request.php

示例4: oAuthUrl

 /**
  * Sign our target URL with OAuth auth stuff.
  *
  * @param string $url
  * @param array $params
  * @return string
  */
 protected function oAuthUrl($url, $params = array())
 {
     // In an ideal world this would be better encapsulated. :)
     $request = OAuthRequest::from_consumer_and_token($this->oauth->consumer, $this->oauth->token, 'GET', $url, $params);
     $request->sign_request($this->oauth->sha1_method, $this->oauth->consumer, $this->oauth->token);
     return $request->to_url();
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:14,代码来源:twitterstreamreader.php

示例5: getYelp

function getYelp($term, $location)
{
    $unsigned_url = "http://api.yelp.com/v2/search?term=" . urlencode($term) . "&location=" . urlencode($location) . "&limit=1";
    // Set your keys here
    $consumer_key = "8LjXkvQ-lcUe7dSlvIHhAQ";
    $consumer_secret = "7AnAzMD4h6mthw27wT48qZFEJoo";
    $token = "B-j7tOmv_GPGzZsfc_VId-cjRMLlBcCq";
    $token_secret = "Hjq6GZOp61HR_JxUgB9_O7HpqKA";
    // Token object built using the OAuth library
    $token = new OAuthToken($token, $token_secret);
    // Consumer object built using the OAuth library
    $consumer = new OAuthConsumer($consumer_key, $consumer_secret);
    // Yelp uses HMAC SHA1 encoding
    $signature_method = new OAuthSignatureMethod_HMAC_SHA1();
    // Build OAuth Request using the OAuth PHP library. Uses the consumer and token object created above.
    $oauthrequest = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $unsigned_url);
    // Sign the request
    $oauthrequest->sign_request($signature_method, $consumer, $token);
    // Get the signed URL
    $signed_url = $oauthrequest->to_url();
    // Send Yelp API Call
    $ch = curl_init($signed_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $data = curl_exec($ch);
    // Yelp response
    curl_close($ch);
    // Handle Yelp response data
    //$response = json_decode($data);
    // Print it for debugging
    //print_r($response);
    return $data;
}
开发者ID:anirudhakarwa,项目名称:TravelSuggest,代码行数:33,代码来源:example.php

示例6: signParameters

function signParameters($oldparms, $endpoint, $method, $key, $secret, $org_secret, $org_id, $org_desc)
{
    global $last_base_string;
    $parms = $oldparms;
    $parms["lti_version"] = "LTI-1p0";
    $parms["lti_message_type"] = "basic-lti-launch-request";
    if ($org_id) {
        $parms["tool_consumer_instance_guid"] = $org_id;
    }
    if ($org_desc) {
        $parms["tool_consumer_instance_description"] = $org_desc;
        $parms["tool_consumer_instance_name"] = $org_desc;
    }
    $parms["basiclti_submit"] = "Launch Tool";
    $parms["oauth_callback"] = "about:blank";
    if ($org_secret) {
        $oauth_consumer_secret = $org_secret;
        $oauth_consumer_key = $org_id;
    } else {
        $oauth_consumer_secret = $secret;
        $oauth_consumer_key = $key;
    }
    $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
    $test_consumer = new OAuthConsumer($oauth_consumer_key, $oauth_consumer_secret, NULL);
    $acc_req = OAuthRequest::from_consumer_and_token($test_consumer, $test_token, $method, $endpoint, $parms);
    $acc_req->sign_request($hmac_method, $test_consumer, $test_token);
    // Pass this back up "out of band" for debugging
    $last_base_string = $acc_req->get_signature_base_string();
    $newparms = $acc_req->get_parameters();
    return $newparms;
}
开发者ID:ericvanboven,项目名称:IMathAS,代码行数:31,代码来源:blti_util.php

示例7: getFeed

 public function getFeed()
 {
     $biz = 'gjelina-venice-2';
     $url = 'http://api.yelp.com/v2/business/' . $biz;
     $this->token = env('YELP_ACCESS_TOKEN');
     $this->secret = env('YELP_ACCESS_TOKEN_SECRET');
     $this->consumer_key = env('YELP_CONSUMER_KEY');
     $this->consumer_secret = env('YELP_CONSUMER_SECRET');
     // Token object built using the OAuth library
     $token = new OAuthToken($this->token, $this->token_secret);
     // Consumer object built using the OAuth library
     $consumer = new OAuthConsumer($this->consumer_key, $this->consumer_secret);
     // Yelp uses HMAC SHA1 encoding
     $signature_method = new OAuthSignatureMethod_HMAC_SHA1();
     // Build OAuth Request using the OAuth PHP library. Uses the consumer and token object created above.
     $oauthrequest = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $url);
     // Sign the request
     $oauthrequest->sign_request($signature_method, $consumer, $token);
     // Get the signed URL
     $signed_url = $oauthrequest->to_url();
     //$signed_url = str_replace("gjelina-venice-2?", "gjelina-venice-2&", $signed_url);
     echo $signed_url . "<br><br>";
     $r = $this->callCurl($signed_url);
     $arr = json_decode($r);
     printR($arr);
     // foreach($arr->error as $k=>$v) {
     //      echo rawurldecode($v)."<br><br>";
     // }
     printR($r);
     exit;
 }
开发者ID:nowarena,项目名称:homestead,代码行数:31,代码来源:YelpAdapter.php

示例8: get_pco_data

function get_pco_data($url,$method = "GET",$content = Null){
	global $pco_key, $pco_secret, $user_access_token, $user_access_token_secret;

	$test_consumer  = new OAuthConsumer($pco_key, $pco_secret, NULL);
	$access_consumer = new OAuthConsumer($user_access_token, $user_access_token_secret, NULL);

	// build and sign request
	$request = OAuthRequest::from_consumer_and_token($test_consumer,
	  $access_consumer, 
	  $method,
	  $url, 
	  NULL);
	$request->sign_request(new OAuthSignatureMethod_HMAC_SHA1(),
	  $test_consumer, 
	  $access_consumer
	);
	
	if (isset($content)){
		//define request headers
		$headers = array("Accept: application/xml");
		$headers[] = $request->to_header();
		$headers[] = "Content-type: application/xml";
		$response = run_curl($url, $method, $headers, $content);
	}
	else {
		// make GET request
		$response = run_curl($request, $method);
	}
	
	return $response;

}
开发者ID:JohnnySheppard,项目名称:St-Johns-Planning-Center-Extras,代码行数:32,代码来源:common.php

示例9: execute

 protected function execute($arguments = array(), $options = array())
 {
     require_once realpath(dirname(__FILE__) . '/../../../../lib/vendor/OAuth/OAuth.php');
     new sfDatabaseManager($this->configuration);
     sfContext::createInstance($this->createConfiguration('pc_frontend', 'prod'), 'pc_frontend');
     $consumerKey = isset($options['consumer-key']) && $options['consumer-key'] ? $options['consumer-key'] : opOpenSocialToolKit::getOAuthConsumerKey();
     $consumer = new OAuthConsumer($consumerKey, null, null);
     $signatureMethod = new OAuthSignatureMethod_RSA_SHA1_opOpenSocialPlugin();
     $httpOptions = opOpenSocialToolKit::getHttpOptions();
     $queueGroups = Doctrine::getTable('ApplicationLifecycleEventQueue')->getQueueGroups();
     $limitRequest = (int) $options['limit-request'];
     $limitRequestApp = (int) $options['limit-request-app'];
     $allRequest = 0;
     foreach ($queueGroups as $group) {
         $application = Doctrine::getTable('Application')->find($group[0]);
         $links = $application->getLinks();
         $linkHash = array();
         foreach ($links as $link) {
             if (isset($link['rel']) && isset($link['href'])) {
                 $method = isset($link['method']) ? strtolower($link['method']) : '';
                 $method = 'post' !== $method ? 'get' : 'post';
                 $linkHash[$link['rel']] = array('href' => $link['href'], 'method' => $method);
             }
         }
         $queues = Doctrine::getTable('ApplicationLifecycleEventQueue')->getQueuesByApplicationId($group[0], $limitRequestApp);
         foreach ($queues as $queue) {
             if (!isset($linkHash[$queue->getName()])) {
                 $queue->delete();
                 continue;
             }
             $href = $linkHash[$queue->getName()]['href'];
             $method = $linkHash[$queue->getName()]['method'];
             $oauthRequest = OAuthRequest::from_consumer_and_token($consumer, null, $method, $href, $queue->getParams());
             $oauthRequest->sign_request($signatureMethod, $consumer, null);
             $client = new Zend_Http_Client();
             if ('post' !== $method) {
                 $method = 'get';
                 $client->setMethod(Zend_Http_Client::GET);
                 $href .= '?' . $oauthRequest->to_postdata();
             } else {
                 $client->setMethod(Zend_Http_Client::POST);
                 $client->setHeaders(Zend_Http_Client::CONTENT_TYPE, Zend_Http_Client::ENC_URLENCODED);
                 $client->setRawData($oauthRequest->to_postdata());
             }
             $client->setConfig($httpOptions);
             $client->setUri($href);
             $client->setHeaders($oauthRequest->to_header());
             $response = $client->request();
             if ($response->isSuccessful()) {
                 $queue->delete();
             }
             $allRequest++;
             if ($limitRequest && $limitRequest <= $allRequest) {
                 break 2;
             }
         }
         $application->free(true);
         $queues->free(true);
     }
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:60,代码来源:opOpenSocialExecuteLifecycleEventTask.class.php

示例10: __construct

 public function __construct($consumer, $token, $http_method, $http_url, $parameters = array())
 {
     $this->OAuthRequest = OAuthRequest::from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters);
     $this->OAuthRequest->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, $token);
     $this->method = $http_method;
     $this->parameters = is_array($parameters) ? $parameters : array($parameters);
 }
开发者ID:nise-nabe,项目名称:opCalendarPlugin,代码行数:7,代码来源:opCalendarApi.class.php

示例11: brukar_client_oauth_callback

function brukar_client_oauth_callback()
{
    require_once drupal_get_path('module', 'brukar_common') . '/OAuth.php';
    $method = new OAuthSignatureMethod_HMAC_SHA1();
    $consumer = new OAuthConsumer(variable_get('brukar_consumer_key'), variable_get('brukar_consumer_secret'));
    if (isset($_SESSION['auth_oauth']) && $_SESSION['auth_oauth']['oauth_token'] == $_GET['oauth_token']) {
        unset($_GET['oauth_token']);
        $tmp = new OAuthToken($_SESSION['auth_oauth']['oauth_token'], $_SESSION['auth_oauth']['oauth_token_secret']);
        $req = OAuthRequest::from_consumer_and_token($consumer, $tmp, 'GET', variable_get('brukar_url') . 'server/oauth/access_token', array());
        $req->sign_request($method, $consumer, $tmp);
        parse_str(trim(file_get_contents($req->to_url())), $token);
        unset($_SESSION['auth_oauth']);
        if (count($token) > 0) {
            $_SESSION['_brukar_access_token'] = array('token' => $token['oauth_token'], 'token_secret' => $token['oauth_token_secret']);
            $token = new OAuthToken($token['oauth_token'], $token['oauth_token_secret']);
            $req = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', variable_get('brukar_url') . 'server/oauth/user', array());
            $req->sign_request($method, $consumer, $token);
            brukar_client_login((array) json_decode(trim(file_get_contents($req->to_url()))));
        }
    }
    $debug_data = array('cookie' => $_COOKIE, 'request_uri' => request_uri(), 'auth_oauth' => isset($_SESSION['auth_oauth']) ? $_SESSION['auth_oauth'] : 'no auth_oauth');
    watchdog('brukar_client', 'User login failed.<br/>Debug data:<br/><pre>!debug_data</pre><br/>', array('!debug_data' => print_r($debug_data, TRUE)), WATCHDOG_ERROR);
    drupal_set_message(t('Noe gikk feil under innlogging.'), 'warning');
    drupal_goto('<front>');
}
开发者ID:evenos,项目名称:drupal7-module-brukar,代码行数:25,代码来源:brukar_client.oauth.php

示例12: sign

 /**
  * Adds a signature to the request
  *
  * @access public
  * @author Joel Bout, <joel@taotesting.com>
  * @param $authorizationHeader Move the signature parameters into the Authorization header of the request
  */
 public function sign(common_http_Request $request, common_http_Credentials $credentials, $authorizationHeader = false)
 {
     if (!$credentials instanceof tao_models_classes_oauth_Credentials) {
         throw new tao_models_classes_oauth_Exception('Invalid credentals: ' . gettype($credentials));
     }
     $oauthRequest = $this->getOauthRequest($request);
     $dataStore = new tao_models_classes_oauth_DataStore();
     $consumer = $dataStore->getOauthConsumer($credentials);
     $token = $dataStore->new_request_token($consumer);
     $allInitialParameters = array();
     $allInitialParameters = array_merge($allInitialParameters, $request->getParams());
     $allInitialParameters = array_merge($allInitialParameters, $request->getHeaders());
     //oauth_body_hash is used for the signing computation
     if ($authorizationHeader) {
         $oauth_body_hash = base64_encode(sha1($request->getBody(), true));
         //the signature should be ciomputed from encoded versions
         $allInitialParameters = array_merge($allInitialParameters, array("oauth_body_hash" => $oauth_body_hash));
     }
     //$authorizationHeader = self::buildAuthorizationHeader($signatureParameters);
     $signedRequest = OAuthRequest::from_consumer_and_token($consumer, $token, $oauthRequest->get_normalized_http_method(), $oauthRequest->getUrl(), $allInitialParameters);
     $signature_method = new OAuthSignatureMethod_HMAC_SHA1();
     //common_logger::d('Base string: '.$signedRequest->get_signature_base_string());
     $signedRequest->sign_request($signature_method, $consumer, $token);
     common_logger::d('Base string from TAO/Joel: ' . $signedRequest->get_signature_base_string());
     if ($authorizationHeader) {
         $combinedParameters = $signedRequest->get_parameters();
         $signatureParameters = array_diff_assoc($combinedParameters, $allInitialParameters);
         $signatureParameters["oauth_body_hash"] = base64_encode(sha1($request->getBody(), true));
         $signatureHeaders = array("Authorization" => self::buildAuthorizationHeader($signatureParameters));
         $signedRequest = new common_http_Request($signedRequest->getUrl(), $signedRequest->get_normalized_http_method(), $request->getParams(), array_merge($signatureHeaders, $request->getHeaders()), $request->getBody());
     } else {
         $signedRequest = new common_http_Request($signedRequest->getUrl(), $signedRequest->get_normalized_http_method(), $signedRequest->get_parameters(), $request->getHeaders(), $request->getBody());
     }
     return $signedRequest;
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:42,代码来源:class.Service.php

示例13: newRequestMessage

 /**
  * @return OAuthRequest
  */
 public function newRequestMessage($method, $url, $parameters)
 {
     if (!isset($method)) {
         $method = $this->getProperty("httpMethod");
         if ($method == null) {
             $method = $this->consumer->getProperty("httpMethod");
             if ($method == null) {
                 $method = "GET";
             }
         }
     }
     $message = OAuthRequest::from_consumer_and_token($this->consumer, $this->accessToken, $method, $url, $parameters);
     $signatureMethod = null;
     if ($parameters[OAuth::$OAUTH_SIGNATURE_METHOD] == OAuth::$RSA_SHA1) {
         $signatureMethod = new OAuthSignatureMethod_RSA_SHA1();
     } else {
         if ($parameters[OAuth::$OAUTH_SIGNATURE_METHOD] == OAuth::$HMAC_SHA1) {
             $signatureMethod = new OAuthSignatureMethod_HMAC_SHA1();
         } else {
             //PLAINTEXT
             $signatureMethod = new OAuthSignatureMethod_PLAINTEXT();
         }
     }
     $message->sign_request($signatureMethod, $this->consumer, $this->tokenSecret);
     return $message;
 }
开发者ID:emma5021,项目名称:toba,代码行数:29,代码来源:OAuthAccessor.php

示例14: immediate_update_outcome_in_canvas

function immediate_update_outcome_in_canvas($oauth_consumer_key, $secret, $lti_sourced_id, $lis_outcome_service_url, $score)
{
    set_time_limit(180);
    $xmlRequest = "<?xml version = \"1.0\" encoding = \"UTF-8\"?>\n<imsx_POXEnvelopeRequest xmlns=\"http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0\">\n    <imsx_POXHeader>\n        <imsx_POXRequestHeaderInfo>\n            <imsx_version>V1.0</imsx_version>\n            <imsx_messageIdentifier>999999123</imsx_messageIdentifier>\n        </imsx_POXRequestHeaderInfo>\n    </imsx_POXHeader>\n    <imsx_POXBody>\n        <replaceResultRequest>\n            <resultRecord>\n                <sourcedGUID>\n                    <sourcedId>{$lti_sourced_id}</sourcedId>\n                </sourcedGUID>\n                <result>\n                    <resultScore>\n                        <language>en</language>\n                        <textString>" . $score . "</textString>\n                    </resultScore>\n                </result>\n            </resultRecord>\n        </replaceResultRequest>\n    </imsx_POXBody>\n</imsx_POXEnvelopeRequest>";
    $hash = base64_encode(sha1($xmlRequest, TRUE));
    $params = array('oauth_body_hash' => $hash);
    $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
    $consumer = new OAuthConsumer($oauth_consumer_key, $secret, NULL);
    $req = OAuthRequest::from_consumer_and_token($consumer, NULL, 'POST', $lis_outcome_service_url, $params);
    $req->sign_request($hmac_method, $consumer, NULL);
    $params = $req->get_parameters();
    $header = $req->to_header();
    $header .= "\nContent-type: application/xml";
    $ext_response = do_post_request($lis_outcome_service_url, $xmlRequest, $header);
    $ext_doc = new DOMDocument();
    set_error_handler(array($this, 'HandleXmlError'));
    $ext_doc->loadXML($ext_response);
    restore_error_handler();
    $ext_nodes = domnode_to_array($ext_doc->documentElement);
    if (!isset($ext_nodes['imsx_POXHeader']['imsx_POXResponseHeaderInfo']['imsx_statusInfo']['imsx_codeMajor'])) {
        throw new Exception("No imsx_codeMajor from outcome service for " . $lti_sourced_id);
    }
    if ($ext_nodes['imsx_POXHeader']['imsx_POXResponseHeaderInfo']['imsx_statusInfo']['imsx_codeMajor'] != 'success' && isset($ext_nodes['imsx_POXHeader']['imsx_POXResponseHeaderInfo']['imsx_statusInfo']['imsx_description']) && $ext_nodes['imsx_POXHeader']['imsx_POXResponseHeaderInfo']['imsx_statusInfo']['imsx_description'] != 'User is no longer in course') {
        throw new Exception("No success code from outcome service for " . $lti_sourced_id);
    }
}
开发者ID:ryanboyd,项目名称:2015fall-psy301-writing-assn,代码行数:26,代码来源:process2.php

示例15: _getYelpRequest

 private function _getYelpRequest($yelp_id)
 {
     $cache = $this->cache;
     if (($data = $cache->load(md5($yelp_id))) === false) {
         // For example, request business with id 'the-waterboy-sacramento'
         $unsigned_url = "http://api.yelp.com/v2/business/{$yelp_id}";
         // Token object built using the OAuth library
         $token = new OAuthToken($this->_token, $this->_token_secret);
         // Consumer object built using the OAuth library
         $consumer = new OAuthConsumer($this->_consumer_key, $this->_consumer_secret);
         // Yelp uses HMAC SHA1 encoding
         $signature_method = new OAuthSignatureMethod_HMAC_SHA1();
         // Build OAuth Request using the OAuth PHP library. Uses the consumer and token object created above.
         $oauthrequest = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $unsigned_url);
         // Sign the request
         $oauthrequest->sign_request($signature_method, $consumer, $token);
         // Get the signed URL
         $signed_url = $oauthrequest->to_url();
         // Send Yelp API Call
         $ch = curl_init($signed_url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         $data = curl_exec($ch);
         // Yelp response
         curl_close($ch);
         // Handle Yelp response data
         $response = json_decode($data);
         $cache->save($response, md5($yelp_id));
     }
     return $data;
 }
开发者ID:evinw,项目名称:project_bloom_magento,代码行数:31,代码来源:Data.php


注:本文中的OAuthRequest::from_consumer_and_token方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。