Exemplo n.º 1
0
 public function sendRequest($biz_content)
 {
     $custom_send = new AlipayMobilePublicMessageCustomSendRequest();
     $custom_send->setBizContent($biz_content);
     require FUWU_PATH . 'config.php';
     $aop = new AopClient();
     $aop->appId = FUWU_APPID;
     $aop->rsaPrivateKeyFilePath = $config['merchant_private_key_file'];
     $result = $aop->execute($custom_send);
     return $result;
 }
Exemplo n.º 2
0
 /**
  * 使用sdk中的异步单发消息接口,发送组装好的信息
  *
  * @param unknown $biz_content        	
  */
 public function sendRequest($biz_content)
 {
     $custom_send = new AlipayMobilePublicMessageCustomSendRequest();
     $custom_send->setBizContent($biz_content);
     return aopclient_request_execute($custom_send);
 }
Exemplo n.º 3
0
 private function openPush($openid, $packet)
 {
     import_third('aop.request.AlipayMobilePublicMessageCustomSendRequest');
     $request = new \AlipayMobilePublicMessageCustomSendRequest();
     $set = array();
     $set['toUserId'] = $openid;
     $set['createTime'] = TIMESTAMP * 1000;
     if ($packet['type'] == Platform::POCKET_TEXT) {
         $packet['content'] = str_replace('微信', 'WeChat', $packet['content']);
         $set['msgType'] = 'text';
         $set['text'] = array();
         $set['text']['content'] = $packet['content'];
         $request->setBizContent(json_encode($set));
         $resp = $this->client->execute($request);
         if ($resp->alipay_mobile_public_message_custom_send_response->code != 200) {
             Log::write($resp->alipay_mobile_public_message_custom_send_response->msg, Log::WARN);
         }
     }
     if ($packet['type'] == Platform::POCKET_NEWS) {
         $set['msgType'] = 'image-text';
         $total = count($packet['news']);
         $times = ceil($total / 4);
         for ($i = 0; $i < $times; $i++) {
             $news = array_slice($packet['news'], $i * 4, 4);
             $set['articles'] = array();
             foreach ($news as $row) {
                 $set['articles'][] = array("title" => $row['title'], "desc" => $row['description'], "imageUrl" => $row['picurl'], "actionName" => "查看详情", "url" => $row['url'], "authType" => "loginAuth");
             }
             $request->setBizContent(json_encode($set));
             $resp = $this->client->execute($request);
             if ($resp->alipay_mobile_public_message_custom_send_response->code != 200) {
                 Log::write($resp->alipay_mobile_public_message_custom_send_response->msg, Log::WARN);
             }
         }
     }
 }