當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OAuth::setversion方法代碼示例

本文整理匯總了PHP中OAuth::setversion方法的典型用法代碼示例。如果您正苦於以下問題:PHP OAuth::setversion方法的具體用法?PHP OAuth::setversion怎麽用?PHP OAuth::setversion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OAuth的用法示例。


在下文中一共展示了OAuth::setversion方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: floor

$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
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
開發者ID:ems123,項目名稱:appdirect--aouthclient-php,代碼行數:31,代碼來源:php-oauth-ad.php


注:本文中的OAuth::setversion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。