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


PHP OAuth::setAuthType方法代码示例

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


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

示例1: GetReportsResponse

 public function GetReportsResponse($requestParameters, $requestBody, $oauthRequestUri)
 {
     $this->context->IppConfiguration->Logger->CustomLogger->Log(TraceLevel::Info, "Called PrepareRequest method");
     // This step is required since the configuration settings might have been changed.
     $this->RequestCompressor = CoreHelper::GetCompressor($this->context, true);
     $this->ResponseCompressor = CoreHelper::GetCompressor($this->context, false);
     $this->RequestSerializer = CoreHelper::GetSerializer($this->context, true);
     $this->ResponseSerializer = CoreHelper::GetSerializer($this->context, false);
     // Determine dest URI
     $requestUri = '';
     if ($requestParameters->ApiName) {
         // Example: "https://appcenter.intuit.com/api/v1/Account/AppMenu"
         $requestUri = $this->context->baseserviceURL . $requestParameters->ApiName;
     } else {
         if ($oauthRequestUri) {
             // Prepare the request Uri from base Uri and resource Uri.
             $requestUri = $oauthRequestUri;
         } else {
             if ($requestParameters->ResourceUri) {
                 $requestUri = $this->context->baseserviceURL . $requestParameters->ResourceUri;
             } else {
             }
         }
     }
     $oauth = new OAuth($this->context->requestValidator->ConsumerKey, $this->context->requestValidator->ConsumerSecret);
     $oauth->setToken($this->context->requestValidator->AccessToken, $this->context->requestValidator->AccessTokenSecret);
     $oauth->enableDebug();
     $oauth->setAuthType(OAUTH_AUTH_TYPE_AUTHORIZATION);
     $oauth->disableSSLChecks();
     $httpHeaders = array();
     if ('QBO' == $this->context->serviceType || 'QBD' == $this->context->serviceType) {
         // IDS call
         $httpHeaders = array('accept' => 'application/json');
         // Log Request Body to a file
         $this->RequestLogging->LogPlatformRequests($requestBody, $requestUri, $httpHeaders, TRUE);
         if ($this->ResponseCompressor) {
             $this->ResponseCompressor->PrepareDecompress($httpHeaders);
         }
     } else {
         // IPP call
         $httpHeaders = array('accept' => 'application/json');
     }
     try {
         $OauthMethod = OAUTH_HTTP_METHOD_GET;
         $oauth->fetch($requestUri, $requestBody, $OauthMethod, $httpHeaders);
     } catch (OAuthException $e) {
         //echo "ERROR:\n";
         //print_r($e->getMessage()) . "\n";
         list($response_code, $response_xml, $response_headers) = $this->GetOAuthResponseHeaders($oauth);
         $this->RequestLogging->LogPlatformRequests($response_xml, $requestUri, $response_headers, FALSE);
         return FALSE;
     }
     list($response_code, $response_xml, $response_headers) = $this->GetOAuthResponseHeaders($oauth);
     // Log Request Body to a file
     $this->RequestLogging->LogPlatformRequests($response_xml, $requestUri, $response_headers, FALSE);
     return array($response_code, $response_xml);
 }
开发者ID:andrewhook,项目名称:SampleApp-PHP-for-OpenId-OAuth-V3APICalls,代码行数:57,代码来源:RestServiceHandler.php

示例2: OAuth

<?php

require "config.inc.php";
try {
    $o = new OAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_AUTHORIZATION);
    $access_token_info = unserialize(file_get_contents(OAUTH_TMP_DIR . "/access_token_resp"));
    $o->setToken($access_token_info["oauth_token"], $access_token_info["oauth_token_secret"]);
    /* the following bit refreshes the token using the session handle (http://wiki.oauth.net/ScalableOAuth) ... you don't need it unless your original access token is invalid but you'll need to audit this yourself, for example sakes we'll pretend it has expired. */
    if (!empty($access_token_info["oauth_session_handle"])) {
        $o->setAuthType(OAUTH_AUTH_TYPE_URI);
        $access_token_info = $o->getAccessToken("https://api.login.yahoo.com/oauth/v2/get_token", $access_token_info["oauth_session_handle"]);
        $o->setToken($access_token_info["oauth_token"], $access_token_info["oauth_token_secret"]);
        $o->setAuthType(OAUTH_AUTH_TYPE_AUTHORIZATION);
        file_put_contents(OAUTH_TMP_DIR . "/access_token_resp", serialize($access_token_info));
    }
    /* done refreshing access token, time to do some fetching! */
    $query = rawurlencode("select * from social.profile where guid=me");
    $o->fetch("http://query.yahooapis.com/v1/yql?q={$query}&format=xml");
    $response_info = $o->getLastResponseInfo();
    header("Content-Type: {$response_info["content_type"]}");
    echo $o->getLastResponse();
} catch (OAuthException $E) {
    echo "Exception caught!\n";
    echo "Response: " . $E->lastResponse . "\n";
}
开发者ID:checkout51,项目名称:pecl-web_services-oauth,代码行数:25,代码来源:exec_yql_refresh_token.php

示例3: printf

    $request_token_info = $oauth->getRequestToken(GOOGLE_OAUTH_REQUEST_TOKEN_API . "?scope={$scopes}");
    printf("Request token: %s\n", $request_token_info["oauth_token"]);
    printf("Request token secret: %s\n\n", $request_token_info["oauth_token_secret"]);
    printf("I think I got a valid request token, navigate your www client to:\n\n%s?oauth_token=%s\n\nOnce you finish authorizing, hit ENTER or INTERRUPT to exit\n", GOOGLE_OAUTH_AUTHORIZE_API, $request_token_info["oauth_token"]);
    $in = fopen("php://stdin", "r");
    fgets($in, 255);
    $oauth->setToken($request_token_info["oauth_token"], $request_token_info["oauth_token_secret"]);
    /* grab the access token, which is your persistent token which you use for future requests */
    printf("Grabbing an access token...\n");
    $access_token_info = $oauth->getAccessToken(GOOGLE_OAUTH_ACCESS_TOKEN_API);
    printf("Access token: %s\n", $access_token_info["oauth_token"]);
    printf("Access token secret: %s\n\n", $access_token_info["oauth_token_secret"]);
    printf("Fetching contacts in JSON via %s\n", GOOGLE_POCO_CONTACT_INFO_API);
    $oauth->setToken($access_token_info["oauth_token"], $access_token_info["oauth_token_secret"]);
    /* put the OAuth params into the Authorization header */
    $oauth->setAuthType(OAUTH_AUTH_TYPE_AUTHORIZATION);
    $oauth->fetch(GOOGLE_POCO_CONTACT_INFO_API);
    /* from this point on OAuth is over, now handling the JSON response is in order */
    $json = json_decode($oauth->getLastResponse());
    printf("My contact information at Google: \nGiven name: %s\nFamily name: %s\nDisplay name: %s\n\n", $json->entry->name->givenName, $json->entry->name->familyName, $json->entry->displayName);
    printf("Fetching all of {$json->entry->displayName}'s contacts in JSON via %s\n", GOOGLE_POCO_ALL_CONTACTS);
    $oauth->fetch(GOOGLE_POCO_ALL_CONTACTS);
    $json = json_decode($oauth->getLastResponse());
    printf("=== Total contacts: %d, showing: %d-%d ===\n", $json->totalResults, $json->startIndex + 1, sizeof($json->entry));
    foreach ($json->entry as $n => $contact_object) {
        printf("#%d: %s\n", $n + 1, $contact_object->displayName);
    }
} catch (OAuthException $E) {
    echo "[EXCEPTION] Response: " . $E->lastResponse . "\n";
    echo "[EXCEPTION] More Info: " . $E . "\n";
}
开发者ID:checkout51,项目名称:pecl-web_services-oauth,代码行数:31,代码来源:getContactInfo.php

示例4: GetResponse

 /**
  * Returns the response by calling REST service.
  *
  * @param ServiceContext $requestParameters The parameters
  * @param string $requestBody The request body
  * @param string $oauthRequestUri The OAuth request uri
  * @return array elements are 0: HTTP response code; 1: HTTP response body
  */
 public function GetResponse($requestParameters, $requestBody, $oauthRequestUri)
 {
     $this->context->IppConfiguration->Logger->CustomLogger->Log(TraceLevel::Info, "Called PrepareRequest method");
     // This step is required since the configuration settings might have been changed.
     $this->RequestCompressor = CoreHelper::GetCompressor($this->context, true);
     $this->ResponseCompressor = CoreHelper::GetCompressor($this->context, false);
     $this->RequestSerializer = CoreHelper::GetSerializer($this->context, true);
     $this->ResponseSerializer = CoreHelper::GetSerializer($this->context, false);
     // Determine dest URI
     $requestUri = '';
     if ($requestParameters->ApiName) {
         // Example: "https://appcenter.intuit.com/api/v1/Account/AppMenu"
         $requestUri = $this->context->baseserviceURL . $requestParameters->ApiName;
     } else {
         if ($oauthRequestUri) {
             // Prepare the request Uri from base Uri and resource Uri.
             $requestUri = $oauthRequestUri;
         } else {
             if ($requestParameters->ResourceUri) {
                 $requestUri = $this->context->baseserviceURL . $requestParameters->ResourceUri;
             } else {
             }
         }
     }
     //minorVersion support
     if ($this->context->minorVersion) {
         if ($this->queryToArray($requestUri) == false) {
             $requestUri .= "?minorversion=" . $this->context->minorVersion;
         } else {
             $requestUri .= "&minorversion=" . $this->context->minorVersion;
         }
     }
     $oauth = new OAuth($this->context->requestValidator->ConsumerKey, $this->context->requestValidator->ConsumerSecret);
     $oauth->setToken($this->context->requestValidator->AccessToken, $this->context->requestValidator->AccessTokenSecret);
     $oauth->enableDebug();
     $oauth->setAuthType(OAUTH_AUTH_TYPE_AUTHORIZATION);
     $oauth->disableSSLChecks();
     $httpHeaders = array();
     if ('QBO' == $this->context->serviceType || 'QBD' == $this->context->serviceType) {
         // IDS call
         $httpHeaders = array('host' => parse_url($requestUri, PHP_URL_HOST), 'user-agent' => CoreConstants::USERAGENT, 'accept' => '*/*', 'connection' => 'close', 'content-type' => $requestParameters->ContentType, 'content-length' => strlen($requestBody));
         // Log Request Body to a file
         $this->RequestLogging->LogPlatformRequests($requestBody, $requestUri, $httpHeaders, TRUE);
         if ($requestBody && $this->RequestCompressor) {
             $this->RequestCompressor->Compress($httpHeaders, $requestBody);
         }
         if ($this->ResponseCompressor) {
             $this->ResponseCompressor->PrepareDecompress($httpHeaders);
         }
     } else {
         // IPP call
         $httpHeaders = array('user-agent' => CoreConstants::USERAGENT);
     }
     try {
         if ('POST' == $requestParameters->HttpVerbType) {
             $OauthMethod = OAUTH_HTTP_METHOD_POST;
         } else {
             if ('GET' == $requestParameters->HttpVerbType) {
                 $OauthMethod = OAUTH_HTTP_METHOD_GET;
             }
         }
         $oauth->fetch($requestUri, $requestBody, $OauthMethod, $httpHeaders);
     } catch (OAuthException $e) {
         //echo "ERROR:\n";
         //print_r($e->getMessage()) . "\n";
         list($response_code, $response_xml, $response_headers) = $this->GetOAuthResponseHeaders($oauth);
         $this->RequestLogging->LogPlatformRequests($response_xml, $requestUri, $response_headers, FALSE);
         //echo "Response: {$response_code} - {$response_xml} \n";
         //var_dump($oauth->debugInfo);
         //echo "\n";
         //echo "ERROR MESSAGE: " . $oauth->debugInfo['body_recv'] . "\n"; // Useful info from Intuit
         //echo "\n";
         return FALSE;
     }
     list($response_code, $response_xml, $response_headers) = $this->GetOAuthResponseHeaders($oauth);
     // Log Request Body to a file
     $this->RequestLogging->LogPlatformRequests($response_xml, $requestUri, $response_headers, FALSE);
     return array($response_code, $response_xml);
 }
开发者ID:elliotchance,项目名称:intuit-quickbooks,代码行数:87,代码来源:SyncRestHandler.php

示例5: getServiceObject

 private function getServiceObject($bClearStorage = true)
 {
     if ($bClearStorage) {
         $this->unsetAuthorizedUser();
     }
     $oConsumer = new OAuth($this->sKey, $this->sSecret);
     $oConsumer->setAuthType(OAUTH_AUTH_TYPE_URI);
     $oConsumer->enableDebug();
     return $oConsumer;
 }
开发者ID:blas-dmx,项目名称:trident,代码行数:10,代码来源:BxDolStudioOAuthLib.php

示例6: 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

示例7: fetch

 protected function fetch($sKey, $sSecret, $aParams = array())
 {
     if (!$this->isAuthorized()) {
         return array();
     }
     try {
         $oConsumer = new OAuth($sKey, $sSecret);
         $oConsumer->setAuthType(OAUTH_AUTH_TYPE_URI);
         $oConsumer->enableDebug();
         $oConsumer->setToken($this->oSession->getValue('sys_oauth_token'), $this->oSession->getValue('sys_oauth_secret'));
         $oConsumer->fetch(BX_DOL_OAUTH_URL_FETCH_DATA, $aParams, OAUTH_HTTP_METHOD_POST);
         //echo $oConsumer->getLastResponse(); exit;	//--- Uncomment to debug
         return json_decode($oConsumer->getLastResponse(), true);
     } catch (OAuthException $e) {
         return array();
     }
 }
开发者ID:Baloo7super,项目名称:dolphin,代码行数:17,代码来源:BxDolStudioOAuth.php

示例8: getOauth

 /**
  * Get the instance of fully configured OAuth class
  *
  * @access private
  * @return OAuth
  */
 private function getOauth()
 {
     if (!$this->oauth) {
         $oauth = new OAuth($this->context->requestValidator->ConsumerKey, $this->context->requestValidator->ConsumerSecret);
         $oauth->setToken($this->context->requestValidator->AccessToken, $this->context->requestValidator->AccessTokenSecret);
         $oauth->enableDebug();
         $oauth->setAuthType(OAUTH_AUTH_TYPE_AUTHORIZATION);
         $oauth->disableSSLChecks();
         $this->setOauth($oauth);
     }
     return $this->oauth;
 }
开发者ID:beanworks,项目名称:quickbooks-online-v3-sdk,代码行数:18,代码来源:SyncRestHandler.php


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