本文整理汇总了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'];
}
示例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'];
}
示例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'];
}
示例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);
}
示例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);
}