|
@@ -32,19 +32,45 @@ class SettingService {
|
|
}
|
|
}
|
|
|
|
|
|
public function setAuthUrl(int $channelId, string $redirectUrl) {
|
|
public function setAuthUrl(int $channelId, string $redirectUrl) {
|
|
- $client = new Client();
|
|
|
|
- $res =$client->request('Post', self::BASE_URL.'v1/activities/'.$channelId.'/setAuth', [
|
|
|
|
- 'headers' => [
|
|
|
|
- 'Authorization' => self::TOKEN
|
|
|
|
- ],
|
|
|
|
- 'json' => [
|
|
|
|
- 'method' => 'CUSTOM_VERIFY',
|
|
|
|
- 'redirect_url' => $redirectUrl
|
|
|
|
- ]
|
|
|
|
- ]);
|
|
|
|
- $info = json_decode((string)$res->getBody(),true);
|
|
|
|
|
|
+// $client = new Client();
|
|
|
|
+// $res =$client->request('Post', self::BASE_URL.'v1/activities/'.$channelId.'/setAuth', [
|
|
|
|
+// 'headers' => [
|
|
|
|
+// 'Authorization' => self::TOKEN
|
|
|
|
+// ],
|
|
|
|
+// 'json' => [
|
|
|
|
+// 'method' => 'CUSTOM_VERIFY',
|
|
|
|
+// 'redirect_url' => $redirectUrl
|
|
|
|
+// ]
|
|
|
|
+// ]);
|
|
|
|
+ $curl = curl_init();
|
|
|
|
+ $data = [
|
|
|
|
+ 'method' => 'CUSTOM_VERIFY',
|
|
|
|
+ 'redirect_url' => $redirectUrl
|
|
|
|
+ ];
|
|
|
|
+ $data = json_encode($data);
|
|
|
|
+ curl_setopt_array($curl, array(
|
|
|
|
+ CURLOPT_URL => self::BASE_URL.'v1/activities/'.$channelId.'/setAuth',
|
|
|
|
+ CURLOPT_RETURNTRANSFER => true,
|
|
|
|
+ CURLOPT_ENCODING => '',
|
|
|
|
+ CURLOPT_MAXREDIRS => 10,
|
|
|
|
+ CURLOPT_TIMEOUT => 0,
|
|
|
|
+ CURLOPT_FOLLOWLOCATION => true,
|
|
|
|
+ CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
|
|
+ CURLOPT_CUSTOMREQUEST => 'POST',
|
|
|
|
+ CURLOPT_POSTFIELDS => $data,
|
|
|
|
+ CURLOPT_HTTPHEADER => array(
|
|
|
|
+ 'Authorization: '.self::TOKEN,
|
|
|
|
+ 'Content-Type: application/json'
|
|
|
|
+ ),
|
|
|
|
+ ));
|
|
|
|
+
|
|
|
|
+ $response = curl_exec($curl);
|
|
|
|
+
|
|
|
|
+ curl_close($curl);
|
|
|
|
+
|
|
|
|
+ $info = json_decode((string)$response,true);
|
|
if ($info['status'] !== 'y') {
|
|
if ($info['status'] !== 'y') {
|
|
- throw new ApiException("设置自定义授权url失败--".(string)$res->getBody());
|
|
|
|
|
|
+ throw new ApiException("设置自定义授权url失败--".(string)$response);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|