예제 #1
0
 public function sendPush($payload, $autoCode)
 {
     $data_string = json_encode($payload->toJSON());
     $header = array('Authorization: Basic ' . $autoCode, 'Content-type: application/json');
     //请求
     $httpClient = new NativeHttpClient();
     try {
         return $httpClient->sendRequestByCurl($this->PUSH_API_URL, $data_string, $header);
     } catch (Exception $e) {
         error_log("Maybe connect error. Retry later.");
         //return  json_encode(array("code"=>"400", "message"=>"Maybe connect error. Retry later."));
     }
 }
예제 #2
0
 public function send($data, $autoCode)
 {
     $url = $this->RECEIVE_API_URL . "?msg_ids=" . $data;
     $header = 'Authorization:' . $autoCode;
     //请求头信息
     $context = array('http' => array('method' => $this->RECEIVE_METHOD, 'header' => $header));
     $stream_context = stream_context_create($context);
     //请求
     $httpClient = new NativeHttpClient();
     try {
         //$rs = $httpClient->sendRequest($url, $stream_context);
         return $httpClient->sendRequest($url, $stream_context);
     } catch (Exception $e) {
         //return  json_encode(array("code"=>"400", "message"=>"Maybe connect error. Retry laster."));
         error_log("Maybe connect error. Retry later.");
     }
 }