token=$token; $this->setUrl(); $this->setVal($scene_str); } public function setUrl(){ $url="https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=".$this->token; $this->url=$url; } public function create(){ $http = wx_http::factory($this->url, wx_http::TYPE_CURL); $json = $http->post($this->url, $this->json_data, array( 'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1)', 'Content-Type: application/json; charset=utf-8', 'Content-Length: '. strlen($this->json_data) )); $result = json_decode($json,true); if ((isset($result['errcode']) ) OR (isset($result['errmsg']))) { $this->_errno = $result['errcode']; $this->_error = $result['errmsg']; return FALSE; } return $this->getTicket($result['ticket']); } public function setVal($scene_str){ $data=array(); $data['action_name']='QR_LIMIT_STR_SCENE'; $data['action_info']=array('scene'=>array('scene_str'=>$scene_str)); $this->json_data = json_encode($data); } protected function getTicket($ticket){ return "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=".urlencode($ticket); } }