示例#1
0
 public function text($content)
 {
     $token = $this->getAccessToken($this->mpid);
     $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$token['token']}";
     $res = Curl::httpPost($url, json_encode(['touser' => $this->openid, 'msgtype' => 'text', 'text' => ['content' => $content]]));
     $res = json_decode($res);
     if ($res->errcode === 0) {
         return true;
     } else {
         $this->errmsg = $res->errmsg;
         return false;
     }
 }
示例#2
0
 /**
  * 调用外部url
  * @param $queryUrl
  * @param $param
  * @param string $method
  * @return bool|mixed
  */
 public static function callWebServer($queryUrl, $param, $method = 'get')
 {
     if (empty($queryUrl)) {
         return false;
     }
     $method = strtolower($method);
     $ret = '';
     $param = empty($param) ? array() : $param;
     $curlObj = new Curl();
     if ($method == 'get') {
         $ret = $curlObj->httpGet($queryUrl, GAME_URL, $param);
     } elseif ($method == 'post') {
         $ret = $curlObj->httpPost($queryUrl, GAME_URL, $param);
     }
     if (!empty($ret)) {
         return json_decode($ret, true);
     }
     return true;
 }
示例#3
0
 public function bulk($str)
 {
     $result = array('status' => 0, 'data' => '', 'err' => '');
     if (!strstr(substr($str, -2), PHP_EOL)) {
         $str = $str . "\n";
     }
     // $res = Curl::httpPost($this->_url.$this->_name.'/',json_encode($params),false,true);
     $res = Curl::httpPost($this->_url . '_bulk', $str, false, true);
     if ($res['header']['http_code'] == 200) {
         $fbody = json_decode($res['body'], true);
         $result['status'] = $fbody['errors'] == false ? 1 : 0;
         $result['data'] = $res['body'];
     } elseif ($res['err'] != '') {
         throw new \Exception($res['err']);
     } else {
         $result['status'] = 0;
         $result['data'] = $res['body'];
     }
     return $result;
 }
示例#4
0
 public function open()
 {
     $result = array('status' => 0, 'data' => '', 'err' => '');
     $res = Curl::httpPost($this->_url . $this->_name . '/_open', array(), false, true);
     if ($res['header']['http_code'] == 200) {
         $result['status'] = 1;
         $result['data'] = $res['body'];
     } elseif ($res['err'] != '') {
         throw new \Exception($res['err']);
     } else {
         $result['status'] = 0;
         $result['data'] = $res['body'];
     }
     return $result;
 }