'api',
'op' => 'core',
'task' => 'toAuthorize',
'weid' => $weid,
'time' => $time,
'token' => $token,
'back_url' => urlencode(config('console.thirdWx.backUrl'))
];
self::setLog(self::TYPENAME.'请求参数', $this->startTime(), $params);
$queryArr = [];
foreach ($params as $key=>$param){
$queryArr[] = $key.'='.$param;
}
$result = $url.'?'.implode('&', $queryArr);
self::setLog(self::TYPENAME.'返回结果111', $this->startTime(), ['result'=>$result]);
return $this->response($result);
} catch (\Exception $e) {
$this->setLog(self::TYPENAME.'getAccessToken 远程请求失败', $this->startTime, [$e->getMessage()]);
return $this->error()->fail();
}
}
public function getUserInfo($weichatUid)
{
$url = config('console.thirdWx.url') . self::USERINFO_URL;
$key = config('console.thirdWx.key');
$time = time();
$token = md5(md5($key.$weichatUid.$time));
try {
$params = [
'wechat_uid' => $weichatUid,
'time' => $time,
'token' => $token,
];
$client = new httpClient();
$res = $client->request('post', $url, ['form_params'=>$params]);
$body = $res->getBody();
$data = json_decode($body);
// echo json_encode($url);
// echo "
";
// echo json_encode($params);
// echo "
";
// echo json_encode($data); exit;
return $this->response($data);
} catch (\Exception $e) {
$this->setLog(self::TYPENAME.'getAccessToken 远程请求失败', $this->startTime, [$e->getMessage()]);
$this->error()->fail();
}
}
public function getJsSdk(string $weid, string $urls)
{
$url = config('console.thirdWx.url') . self::JSSDK_URL.'&weid='.$weid;
try {
$params = [
'url' => $urls
];
$client = new httpClient();
$res = $client->request('post', $url, ['form_params'=>$params]);
$body = $res->getBody();
self::setLog(self::TYPENAME, $this->startTime(), [$body]);
$data = json_decode($body);
return $this->response($data);
} catch (\Exception $e) {
$this->setLog(self::TYPENAME.'getJsSdk 远程请求失败', $this->startTime, [$e->getMessage()]);
$this->error()->fail();
}
}
}