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


PHP client::post方法代碼示例

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


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

示例1: generateAccessToken

 /**
  * 通過調用信任登陸accesstoken接口生成access token
  *
  * @param string $code	 * @return string
  */
 public function generateAccessToken($code)
 {
     $args = ['client_id' => $this->getAppKey(), 'client_secret' => $this->getAppSecret(), 'grant_type' => 'authorization_code', 'code' => $code, 'redirect_uri' => $this->getCallbackUrl()];
     $msg = client::post($this->getUrl('token'), ['body' => $args])->json();
     if (isset($msg['error'])) {
         throw new \LogicException("error :" . $msg['error_code'] . "msg  :" . $msg['error']);
     }
     return $msg['access_token'];
 }
開發者ID:453111208,項目名稱:bbc,代碼行數:14,代碼來源:kaixin.php

示例2: generateOpenId

 /**
  * 生成信任登陸open id
  *
  * @return string
  */
 public function generateOpenId()
 {
     $args = ['access_token' => $this->getAccessToken()];
     $msg = client::post($this->getUrl('openid'), ['body' => $args])->json();
     if (isset($msg['error'])) {
         throw new \LogicException("error :" . $msg['error_code'] . "msg  :" . $msg['error']);
     }
     return $msg['uid'];
 }
開發者ID:453111208,項目名稱:bbc,代碼行數:14,代碼來源:weibo.php

示例3: generateAccessToken

 /**
  * 通過調用信任登陸accesstoken接口生成access token
  *
  * @param string $code	 * @return string
  */
 public function generateAccessToken($code)
 {
     $args = ['client_id' => $this->getAppKey(), 'client_secret' => $this->getAppSecret(), 'grant_type' => 'authorization_code', 'code' => $code, 'redirect_uri' => $this->getCallbackUrl()];
     try {
         $msg = client::post($this->getUrl('token'), ['body' => $args])->json();
     } catch (ClientException $e) {
         $msg = $e->getResponse()->json();
         throw new \LogicException("error :" . $msg['error'] . "msg  :" . $msg['error_description']);
     }
     $this->taobaoUserInfo = ['taobao_user_id' => $msg['taobao_user_id'], 'taobao_user_nick' => $msg['taobao_user_nick']];
     return $msg['access_token'];
 }
開發者ID:453111208,項目名稱:bbc,代碼行數:17,代碼來源:taobao.php

示例4: putFile

 /**
  * 上傳文件到七牛,內部使用
  *
  * @param $upToken    上傳憑證
  * @param $key        上傳文件名
  * @param $filePath   上傳文件的路徑
  * @param $params     自定義變量,規格參考
  *                    http://developer.qiniu.com/docs/v6/api/overview/up/response/vars.html#xvar
  * @param $mime       上傳數據的mimeType
  * @param $checkCrc   是否校驗crc32
  *
  * @return array    包含已上傳文件的信息,類似:
  *                                              [
  *                                                  "hash" => "<Hash string>",
  *                                                  "key" => "<Key string>"
  *                                              ]
  */
 public static function putFile($upToken, $key, $filePath, $config, $params, $mime, $checkCrc)
 {
     $fields = array('token' => $upToken, 'file' => self::createFile($filePath, $mime));
     if ($key !== null) {
         $fields['key'] = $key;
     }
     if ($checkCrc) {
         $fields['crc32'] = Qiniu\crc32_file($filePath);
     }
     if ($params) {
         foreach ($params as $k => $v) {
             $fields[$k] = $v;
         }
     }
     $fields['key'] = $key;
     $headers = array('Content-Type' => 'multipart/form-data');
     $response = client::post($config->getUpHost(), $fields, $headers);
     if (!$response->ok()) {
         return array(null, new Error($config->getUpHost(), $response));
     }
     return array($response->json(), null);
 }
開發者ID:kl0428,項目名稱:admin,代碼行數:39,代碼來源:FormUploader.php

示例5: putFile

 public static function putFile($upToken, $key, $filePath, $params, $mime, $checkCrc)
 {
     $fields = array('token' => $upToken, 'file' => self::createFile($filePath, $mime));
     if ($key === null) {
         $fname = 'filename';
     } else {
         $fname = $key;
         $fields['key'] = $key;
     }
     if ($checkCrc) {
         $fields['crc32'] = (new Functions())->crc32_file($filePath);
     }
     if ($params) {
         foreach ($params as $k => $v) {
             $fields[$k] = $v;
         }
     }
     $headers = array('Content-Type' => 'multipart/form-data');
     $response = client::post(Config::$defaultHost, $fields, $headers);
     if (!$response->ok()) {
         return array(null, new Error(Config::$defaultHost, $response));
     }
     return array($response->json(), null);
 }
開發者ID:hhy5861,項目名稱:yii2-ticket,代碼行數:24,代碼來源:FormUploader.php


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