示例#1
0
 public static function getJsToken($token)
 {
     $url = sprintf(self::WECHAT_JS_TOKEN, $token);
     $result = HttpRequest::sendHttpRequest($url);
     $data = json_decode($result['content']);
     $result = isset($data->ticket) ? $data->ticket : Globals::$wechatErrorCode[$data->errcode];
     $status = isset($data->ticket) ? self::OK : self::FAILED;
     return array('status' => $status, 'result' => $result);
 }
示例#2
0
 private function _getOpenReplay($responseId)
 {
     $post_string = $GLOBALS["HTTP_RAW_POST_DATA"];
     $openReplayInfo = OpenReplayModel::model()->with('open_openPlatForm')->findByPk($responseId);
     $apiUrl = $openReplayInfo->open_openPlatForm->apiUrl;
     $token = $openReplayInfo->open_openPlatForm->token;
     $wechatApi = new WechatApi($token);
     $url = $wechatApi->buildSignUrl($apiUrl);
     $result = HttpRequest::sendHttpRequest($url, $post_string, 'POST', array("Content-type: text/xml"));
     return $result['content'] ? $result['content'] : '';
 }
示例#3
0
 public function actionDeleteMenu($wechatId)
 {
     $status = -1;
     $token = $this->_getToken($wechatId);
     $tokenValue = $token['tokenValue'];
     if ($tokenValue) {
         $url = sprintf(Globals::MENU_DELETE_URL, $tokenValue);
         $result = HttpRequest::sendHttpRequest($url);
         $resultData = json_decode($result['content']);
         $status = $resultData->errcode == Globals::WECHAT_RESPONSE_OK ? 1 : -1;
         $msg = $resultData->errcode == Globals::WECHAT_RESPONSE_OK ? '' : Globals::$wechatErrorCode[$resultData->errcode];
     } else {
         $msg = '获取token异常';
     }
     echo json_encode(array('status' => $status, 'msg' => $msg));
 }