Skip to content

Commit ba6352c

Browse files
committed
Update 2.2
1 parent 1ace6aa commit ba6352c

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

api.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,24 @@ public function __construct($channelAccessToken, $channelSecret) {
6767
$this->channelSecret = $channelSecret;
6868
}
6969

70-
public function issueChannelAccessToken(){
70+
public function issueChannelAccessToken($channelId, $channelSecret){
7171
$header = array(
7272
"Content-Type: application/x-www-form-urlencoded"
7373
);
7474

75-
$content = array(
76-
"grant_type=client_credentials",
77-
"client_id=" . $channelId,
78-
"client_secret=" . $channelSecret
75+
$content = http_build_query(
76+
array(
77+
"grant_type" => "client_credentials",
78+
"client_id" => $channelId,
79+
"client_secret" => $channelSecret
80+
)
7981
);
8082

8183
$context = stream_context_create(array(
8284
"http" => array(
8385
"method" => "POST",
8486
"header" => implode("\r\n", $header),
85-
"content" => implode("\r\n", $content),
87+
"content" => $content,
8688
),
8789
));
8890

@@ -102,15 +104,22 @@ public function revokeChannelAccessToken(){
102104
"Content-Type: application/x-www-form-urlencoded"
103105
);
104106

107+
108+
$content = http_build_query(
109+
array(
110+
"access_token" => $this->channelAccessToken
111+
)
112+
);
113+
105114
$context = stream_context_create(array(
106115
"http" => array(
107116
"method" => "POST",
108117
"header" => implode("\r\n", $header),
109-
"content" => "access_token=" . $this->channelAccessToken,
118+
"content" => $content,
110119
),
111120
));
112121

113-
$response = file_get_contents($this->host.'/v2/oauth/accessToken', false, $context);
122+
$response = file_get_contents($this->host.'/v2/oauth/revoke', false, $context);
114123
if (strpos($http_response_header[0], '200') === false) {
115124
http_response_code(500);
116125
error_log("Request failed: " . $response);

0 commit comments

Comments
 (0)