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


PHP RequestUtil::unexpectedStatus方法代码示例

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


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

示例1: _finish

 protected function _finish($code, $originalRedirectUri)
 {
     // This endpoint requires "Basic" auth.
     $clientCredentials = $this->appInfo->getKey() . ":" . $this->appInfo->getSecret();
     $authHeaderValue = "Basic " . base64_encode($clientCredentials);
     $response = RequestUtil::doPostWithSpecificAuth($this->clientIdentifier, $authHeaderValue, $this->userLocale, $this->appInfo->getHost()->getApi(), "1/oauth2/token", array("grant_type" => "authorization_code", "code" => $code, "redirect_uri" => $originalRedirectUri));
     if ($response->statusCode !== 200) {
         throw RequestUtil::unexpectedStatus($response);
     }
     $parts = RequestUtil::parseResponseJson($response->body);
     if (!array_key_exists('token_type', $parts) or !is_string($parts['token_type'])) {
         throw new Exception_BadResponse("Missing \"token_type\" field.");
     }
     $tokenType = $parts['token_type'];
     if (!array_key_exists('access_token', $parts) or !is_string($parts['access_token'])) {
         throw new Exception_BadResponse("Missing \"access_token\" field.");
     }
     $accessToken = $parts['access_token'];
     if (!array_key_exists('uid', $parts) or !is_string($parts['uid'])) {
         throw new Exception_BadResponse("Missing \"uid\" string field.");
     }
     $userId = $parts['uid'];
     if ($tokenType !== "Bearer" && $tokenType !== "bearer") {
         throw new Exception_BadResponse("Unknown \"token_type\"; expecting \"Bearer\", got  " . Client::q($tokenType));
     }
     return array($accessToken, $userId);
 }
开发者ID:kokkez,项目名称:shineisp,代码行数:27,代码来源:WebAuthBase.php

示例2: disableOAuth1AccessToken

 /**
  * Make a Dropbox API call to disable the given OAuth 1 access token.
  *
  * See <a href="https://www.dropbox.com/developers/core/docs#disable-token">/disable_access_token</a>.
  *
  * @param OAuth1AccessToken $oauth1AccessToken
  *
  * @throws Exception
  */
 function disableOAuth1AccessToken($oauth1AccessToken)
 {
     OAuth1AccessToken::checkArg("oauth1AccessToken", $oauth1AccessToken);
     $response = self::doPost($oauth1AccessToken, "1/disable_access_token");
     if ($response->statusCode !== 200) {
         throw RequestUtil::unexpectedStatus($response);
     }
 }
开发者ID:kostya1017,项目名称:our,代码行数:17,代码来源:OAuth1Upgrader.php

示例3: move

 /**
  * Moves a file or folder to a new location.
  *
  * See <a href="https://www.dropbox.com/developers/core/docs#fileops-move">/fileops/move</a>.
  *
  * @param string $fromPath
  *    The source Dropbox path (UTF-8).
  *
  * @param string $toPath
  *    The destination Dropbox path (UTF-8).
  *
  * @return mixed
  *    The <a href="https://www.dropbox.com/developers/core/docs#metadata-details">metadata
  *    object</a> for the destination file or folder.
  *
  * @throws Exception
  */
 function move($fromPath, $toPath)
 {
     Path::checkArgNonRoot("fromPath", $fromPath);
     Path::checkArgNonRoot("toPath", $toPath);
     $response = $this->doPost($this->apiHost, "1/fileops/move", array("root" => "auto", "from_path" => $fromPath, "to_path" => $toPath));
     if ($response->statusCode !== 200) {
         throw RequestUtil::unexpectedStatus($response);
     }
     return RequestUtil::parseResponseJson($response->body);
 }
开发者ID:themexpand,项目名称:xpand-buddy,代码行数:27,代码来源:Client.php

示例4: _finish

 protected function _finish($code, $originalRedirectUri)
 {
     $url = RequestUtil::buildUri($this->appInfo->getHost()->getApi(), "1/oauth2/token");
     $params = array("grant_type" => "authorization_code", "code" => $code, "redirect_uri" => $originalRedirectUri, "locale" => $this->userLocale);
     $curl = RequestUtil::mkCurlWithoutAuth($this->clientIdentifier, $url);
     // Add Basic auth header.
     $basic_auth = $this->appInfo->getKey() . ":" . $this->appInfo->getSecret();
     $curl->addHeader("Authorization: Basic " . base64_encode($basic_auth));
     $curl->set(CURLOPT_POST, true);
     $curl->set(CURLOPT_POSTFIELDS, RequestUtil::buildPostBody($params));
     $curl->set(CURLOPT_RETURNTRANSFER, true);
     $response = $curl->exec();
     if ($response->statusCode !== 200) {
         throw RequestUtil::unexpectedStatus($response);
     }
     $parts = RequestUtil::parseResponseJson($response->body);
     if (!array_key_exists('token_type', $parts) or !is_string($parts['token_type'])) {
         throw new Exception_BadResponse("Missing \"token_type\" field.");
     }
     $tokenType = $parts['token_type'];
     if (!array_key_exists('access_token', $parts) or !is_string($parts['access_token'])) {
         throw new Exception_BadResponse("Missing \"access_token\" field.");
     }
     $accessToken = $parts['access_token'];
     if (!array_key_exists('uid', $parts) or !is_string($parts['uid'])) {
         throw new Exception_BadResponse("Missing \"uid\" string field.");
     }
     $userId = $parts['uid'];
     if ($tokenType !== "Bearer" && $tokenType !== "bearer") {
         throw new Exception_BadResponse("Unknown \"token_type\"; expecting \"Bearer\", got  " . Client::q($tokenType));
     }
     return array($accessToken, $userId);
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:33,代码来源:WebAuthBase.php


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