Skip to content

Commit

Permalink
access-token refresh fixed. closes HMS-Core#7.
Browse files Browse the repository at this point in the history
  • Loading branch information
syslogic committed Dec 25, 2021
1 parent fa13091 commit bad681a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/push_admin/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private function refresh_token()
"Content-Type: application/x-www-form-urlencoded;charset=utf-8"
)));
$this->printLogMethodOperate('refresh_token result:' . json_encode($result), __FUNCTION__ . ':' . __LINE__);
if ($result == null || ! array_key_exists("access_token", $result)) {
if ($result == null || ! property_exists($result, "access_token")) {
$this->printLogMethodOperate('refresh_token result error!', __FUNCTION__ . ':' . __LINE__, Constants::HW_PUSH_LOG_ERROR_LEVEL);
return null;
}
Expand All @@ -139,7 +139,7 @@ private function curl_https_post($url, $data = array(), $header = array())
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$this->printLogMethodOperate('curl_https_post curl send headers:' . json_encode($header), __FUNCTION__ . ':' . __LINE__, Constants::HW_PUSH_LOG_DEBUG_LEVEL);

// resolve SSL: no alternative certificate subject name matches target host name
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // check verify
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
Expand Down Expand Up @@ -182,7 +182,7 @@ public function push_send_msg($msg)
if ($this->is_token_expired()) {
$this->refresh_token();
}

if (empty($this->accesstoken)){
$this->printLogMethodOperate("accesstoken is empty!",
__FUNCTION__ . ':' . __LINE__,Constants::HW_PUSH_LOG_ERROR_LEVEL);
Expand Down Expand Up @@ -217,7 +217,7 @@ public function common_send_msg($msg)
if ($this->is_token_expired()) {
$this->refresh_token();
}

if (empty($this->accesstoken)){
$this->printLogMethodOperate("accesstoken is empty!",
__FUNCTION__ . ':' . __LINE__,Constants::HW_PUSH_LOG_ERROR_LEVEL);
Expand All @@ -232,7 +232,6 @@ public function common_send_msg($msg)

// $result ==> eg: {"code":"80000000","msg":"Success","requestId":"157278422841836431010901"}
$this->printLogMethodOperate('common_send_msg leave result:' . json_encode($result), __FUNCTION__ . ':' . __LINE__);


if (! empty($result)) {
$arrResult = json_decode(json_encode($result), true);
Expand Down

0 comments on commit bad681a

Please sign in to comment.