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


PHP Google_HttpRequest::getUrl方法代码示例

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


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

示例1: sign

 public function sign(Google_HttpRequest $request)
 {
     if ($this->key) {
         $request->setUrl($request->getUrl() . (strpos($request->getUrl(), '?') === false ? '?' : '&') . 'key=' . urlencode($this->key));
     }
     return $request;
 }
开发者ID:lyhiving,项目名称:icampus,代码行数:7,代码来源:Google_AuthNone.php

示例2: decodeHttpResponse

 /**
  * Decode an HTTP Response.
  * @static
  * @throws Google_ServiceException
  * @param Google_HttpRequest $response The http response to be decoded.
  * @return mixed|null
  */
 public static function decodeHttpResponse($response)
 {
     $code = $response->getResponseHttpCode();
     $body = $response->getResponseBody();
     $decoded = null;
     if (intVal($code) >= 300) {
         $decoded = json_decode($body, true);
         $err = 'Error calling ' . $response->getRequestMethod() . ' ' . $response->getUrl();
         if ($decoded != null && isset($decoded['error']['message']) && isset($decoded['error']['code'])) {
             // if we're getting a json encoded error definition, use that instead of the raw response
             // body for improved readability
             $err .= ": ({$decoded['error']['code']}) {$decoded['error']['message']}";
         } else {
             $err .= ": ({$code}) {$body}";
         }
         throw new Google_ServiceException($err, $code, null, $decoded['error']['errors']);
     }
     // Only attempt to decode the response, if the response code wasn't (204) 'no content'
     if ($code != '204') {
         $decoded = json_decode($body, true);
         if ($decoded === null || $decoded === "") {
             throw new Google_ServiceException("Invalid json in service response: {$body}");
         }
     }
     return $decoded;
 }
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:33,代码来源:Google_REST.php

示例3: do_request

 /**
  * Send the request via our curl object.
  *
  * @param curl $curl prepared curl object.
  * @param Google_HttpRequest $request The request.
  * @return string result of the request.
  */
 private function do_request($curl, $request)
 {
     $url = $request->getUrl();
     $method = $request->getRequestMethod();
     switch (strtoupper($method)) {
         case 'POST':
             $ret = $curl->post($url, $request->getPostBody());
             break;
         case 'GET':
             $ret = $curl->get($url);
             break;
         case 'HEAD':
             $ret = $curl->head($url);
             break;
         case 'PUT':
             $ret = $curl->put($url);
             break;
         default:
             throw new coding_exception('Unknown request type: ' . $method);
             break;
     }
     return $ret;
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:30,代码来源:curlio.php

示例4: sign

 /**
  * Include an accessToken in a given apiHttpRequest.
  * @param Google_HttpRequest $request
  * @return Google_HttpRequest
  * @throws Google_AuthException
  */
 public function sign(Google_HttpRequest $request)
 {
     // add the developer key to the request before signing it
     if ($this->developerKey) {
         $requestUrl = $request->getUrl();
         $requestUrl .= strpos($request->getUrl(), '?') === false ? '?' : '&';
         $requestUrl .= 'key=' . urlencode($this->developerKey);
         $request->setUrl($requestUrl);
     }
     // Cannot sign the request without an OAuth access token.
     if (null == $this->token && null == $this->assertionCredentials) {
         return $request;
     }
     // Check if the token is set to expire in the next 30 seconds
     // (or has already expired).
     if ($this->isAccessTokenExpired()) {
         if ($this->assertionCredentials) {
             $this->refreshTokenWithAssertion();
         } else {
             if (!array_key_exists('refresh_token', $this->token)) {
                 throw new Google_AuthException("The OAuth 2.0 access token has expired, " . "and a refresh token is not available. Refresh tokens are not " . "returned for responses that were auto-approved.");
             }
             $this->refreshToken($this->token['refresh_token']);
         }
     }
     // Add the OAuth2 header to the request
     $request->setRequestHeaders(array('Authorization' => 'Bearer ' . $this->token['access_token']));
     return $request;
 }
开发者ID:rockst,项目名称:Google,代码行数:35,代码来源:Google_OAuth2.php


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