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


PHP OAuth::setTimestamp方法代码示例

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


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

示例1: generateLaunchData

 public function generateLaunchData()
 {
     if (!$this->hasRequiredParams()) {
         throw new InvalidLTIConfigurationException("Some required parameters are missing");
     }
     $this->parameters['lti_version'] = array_key_exists('lti_version', $this->parameters) ? $this->parameters['lti_version'] : 'LTI-1p0';
     $this->parameters['lti_message_type'] = array_key_exists('lti_message_type', $this->parameters) ? $this->parameters['lti_message_type'] : 'basic-lti-launch-request';
     $url = $this->toolConfiguration->getLaunchUrl();
     //@TODO: Remove query string parameters and append them to parameters
     $consumer = new \OAuth($this->consumerKey, $this->consumerSecret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
     $timestamp = time();
     $nonce = md5($timestamp);
     $consumer->setTimestamp($timestamp);
     $consumer->setNonce($nonce);
     $signature = $consumer->generateSignature('POST', $url, $this->parameters);
     $this->parameters[LaunchParameters::OAUTH_CONSUMER_KEY] = $this->consumerKey;
     $this->parameters[LaunchParameters::OAUTH_SIGNATURE_METHOD] = 'HMAC-SHA1';
     $this->parameters[LaunchParameters::OAUTH_VERSION] = '1.0';
     $this->parameters[LaunchParameters::OAUTH_TIMESTAMP] = $timestamp;
     $this->parameters[LaunchParameters::OAUTH_NONCE] = $nonce;
     $this->parameters[LaunchParameters::OAUTH_SIGNATURE] = $signature;
     return $this->parameters;
 }
开发者ID:Twenty7,项目名称:ims-lti,代码行数:23,代码来源:ToolConsumer.php

示例2: _oauthReq

 private function _oauthReq($url, $content = null, $reqType = null, $nonce = null, $timestamp = null)
 {
     try {
         $oauth = new OAuth($this->clientKey, $this->clientSecret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
         $oauth->enableDebug();
         $oauth->setToken($this->tokenKey, $this->tokenSecret);
         if (!is_null($nonce)) {
             $oauth->setNonce($nonce);
         }
         if (!is_null($timestamp)) {
             $oauth->setTimestamp($timestamp);
         }
         if (is_null($reqType)) {
             $reqType = OAUTH_HTTP_METHOD_GET;
         }
         $oauth->fetch("{$url}", $content, $reqType);
         $ret = $oauth->getLastResponse();
         return $ret;
     } catch (OAuthException $e) {
         //return $e->lastResponse;
         return $e;
     }
 }
开发者ID:eecian,项目名称:Team08-iPeer,代码行数:23,代码来源:v1_controller.test.php

示例3: floor

$consumer_key = "mykey";
$consumer_secret = "mysecret";
$api_url = "https://mysite.byappdirect.com/api/hostedCheckout/v1/transactions";
$http_method = "POST";
$returnUrl = "http://saralam.com";
$nonce_range = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
$nonce = '';
for ($i = 0; $i < 15; ++$i) {
    $rind = floor((double) rand() / (double) getrandmax() * strlen($nonce_range));
    $nonce .= substr($nonce_range, $rind, 1);
}
$timestamp = time();
$version = "1.0";
$oauth = new OAuth($consumer_key, $consumer_secret);
$oauth->setNonce($nonce);
$oauth->setTimestamp($timestamp);
$oauth->setversion($version);
$sign = $oauth->generateSignature('POST', $api_url);
$oauth_header = 'Authorization: OAuth oauth_version=1.0, oauth_nonce=' . $nonce . ',oauth_timestamp=' . $timestamp . ',oauth_consumer_key=mykey, oauth_signature_method=HMAC-SHA1,oauth_signature=' . $sign;
$ch = curl_init($api_url);
$to_postdata = array("productId" => "37392", "token" => '123446788-dgfgfgfg-uytt', "type" => "PURCHASE", "user" => array("email" => 'testad123@test.com', "firstName" => "Test", "lastName" => "Test"), "company" => array("name" => "Saralam"), "returnUrl" => $returnUrl);
$data_string = json_encode($to_postdata);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json', $oauth_header));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, true);
// DO NOT RETURN HTTP HEADERS
开发者ID:ems123,项目名称:appdirect--aouthclient-php,代码行数:31,代码来源:php-oauth-ad.php

示例4: GetSignedRequestParameters

 /**
  * @see OAuthHanlder::GetSignedRequestParameters()
  */
 public function GetSignedRequestParameters($credentials, $url, $method = NULL)
 {
     if (empty($method)) {
         $method = 'POST';
     }
     $params = array();
     $params['oauth_consumer_key'] = $credentials['oauth_consumer_key'];
     $params['oauth_token'] = $credentials['oauth_token'];
     $params['oauth_signature_method'] = 'HMAC-SHA1';
     $params['oauth_timestamp'] = time();
     $params['oauth_nonce'] = uniqid();
     $params['oauth_version'] = '1.0a';
     $oauth = new OAuth($credentials['oauth_consumer_key'], $credentials['oauth_consumer_secret'], OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_AUTHORIZATION);
     $oauth->setRequestEngine(OAUTH_REQENGINE_CURL);
     $oauth->setVersion('1.0a');
     $oauth->setToken($credentials['oauth_token'], $credentials['oauth_token_secret']);
     $oauth->setTimestamp($params['oauth_timestamp']);
     $oauth->setNonce($params['oauth_nonce']);
     $oauth->setVersion($params['oauth_version']);
     $signature = $oauth->generateSignature(self::$OAUTH_METHOD_ENUMS[$method], $url);
     $params['oauth_signature'] = $signature;
     return $params;
 }
开发者ID:trancerr,项目名称:apiadlib,代码行数:26,代码来源:PeclOAuthHandler.php

示例5: OAuth

<?php

require 'server.inc';
$x = new OAuth('conskey', 'conssecret', OAUTH_SIG_METHOD_PLAINTEXT);
$x->setRequestEngine(OAUTH_REQENGINE_STREAMS);
$x->setTimestamp(12345);
$x->setNonce('testing');
$port = random_free_port();
$pid = http_server("tcp://127.0.0.1:{$port}", array("HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 40\r\n\r\noauth_token=1234&oauth_token_secret=4567"), $output);
$x->setAuthType(OAUTH_AUTH_TYPE_URI);
$x->setToken("key", "secret");
var_dump($x->getAccessToken("http://127.0.0.1:{$port}/test"));
fseek($output, 0, SEEK_SET);
var_dump(stream_get_contents($output));
http_server_kill($pid);
开发者ID:badlamer,项目名称:hhvm,代码行数:15,代码来源:plaintext2.php


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