public function qrAction() { $url = I('get.raw'); $url = base64_decode($url); import_third('qrcode.phpqrcode'); \QRcode::png($url, false, QR_ECLEVEL_Q, 8); }
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); } } } }