当前位置: 首页>>代码示例>>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;未经允许,请勿转载。