Home > Backend Development > PHP Tutorial > The latest and most comprehensive API interface of WeChat 5.0 developed based on EaglePHP framework v2.7

The latest and most comprehensive API interface of WeChat 5.0 developed based on EaglePHP framework v2.7

WBOY
Release: 2016-07-25 08:49:07
Original
901 people have browsed it
Code source: http://www.eaglephp.com
Applicable platform: window/Linux
Dependent projects: EaglePHP framework

Includes WeChat 5.0 API basic interface, custom menu, and advanced interface, as follows:
1. Receive user messages .
2. Reply to the user.
3. Accept event push.
4. Conversation interface custom menu.
5. Voice recognition.
6. Customer service interface.
7. OAuth2.0 web authorization.
8. Generate QR code with parameters.
9. Obtain the user’s geographical location.
10. Obtain basic user information.
11. Get the followers list.
12. User grouping.
  1. /**
  2. * WeChat public platform API
  3. *
  4. * @author maojianlw@139.com
  5. * [url=home.php?mod=space&uid=17823]@LINK[/url] http://www.eaglephp.com
  6. */
  7. class WeixinChat
  8. {
  9. private $token;
  10. private $appid;
  11. private $appsecret;
  12. private $access_token;
  13. // Received data
  14. private $_receive = array();
  15. private $_reply = '';
  16. // Interface error code
  17. private $errCode = '';
  18. // Interface error message
  19. private $errMsg = '' ;
  20. // Log in with WeChat oauth to get the code
  21. const CONNECT_OAUTH_AUTHORIZE_URL = 'https://open.weixin.qq.com/connect/oauth2/authorize?';
  22. // Log in with WeChat oauth and exchange the code for webpage authorization access_token
  23. const SNS_OAUTH_ACCESS_TOKEN_URL = 'https://api.weixin.qq.com/sns/oauth2/access_token?';
  24. // WeChat oauth login refresh access_token (if necessary)
  25. const SNS_OAUTH_REFRESH_TOKEN_URL = 'https://api.weixin.qq .com/sns/oauth2/refresh_token?';
  26. // Exchange ticket for QR code
  27. const SHOW_QRCODE_URL = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?';
  28. // WeChat oauth login pulls user information (needs scope is snsapi_userinfo)
  29. const SNS_USERINFO_URL = 'https://api.weixin.qq.com/sns/userinfo?';
  30. // Request api prefix
  31. const API_URL_PREFIX = 'https: //api.weixin.qq.com/cgi-bin';
  32. // Custom menu creation
  33. const MENU_CREATE_URL = '/menu/create?';
  34. // Custom menu query
  35. const MENU_GET_URL = '/menu /get?';
  36. // Custom menu deletion
  37. const MENU_DELETE_URL = '/menu/delete?';
  38. // Get access_token
  39. const AUTH_URL = '/token?grant_type=client_credential&';
  40. // Get user Basic information
  41. const USER_INFO_URL = '/user/info?';
  42. // Get the follower list
  43. const USER_GET_URL = '/user/get?';
  44. // Query the group
  45. const GROUPS_GET_URL = '/groups/get? ';
  46. // Create a group
  47. const GROUPS_CREATE_URL = '/groups/create?';
  48. // Modify the group name
  49. const GROUPS_UPDATE_URL = '/groups/update?';
  50. // Move user groups
  51. const GROUPS_MEMBERS_UPDATE_URL = '/groups/members/update?';
  52. //Send customer service message
  53. const MESSAGE_CUSTOM_SEND_URL = '/message/custom/send?';
  54. //Create QR code ticket
  55. const QRCODE_CREATE_URL = '/qrcode/create? ';
  56. /**
  57. * Initialization configuration data
  58. * @param array $options
  59. */
  60. public function __construct($options)
  61. {
  62. $this->token = isset($options['token']) ? $options['token'] : '';
  63. $this->appid = isset($options['appid']) ? $options['appid'] : '';
  64. $this->appsecret = isset($options['appsecret' ]) ? $options['appsecret'] : '';
  65. }
  66. /**
  67. * Get incoming messages
  68. * When an ordinary WeChat user sends a message to a public account, the WeChat server will POST the XML data packet of the message to the URL filled in by the developer.
  69. */
  70. public function getRev()
  71. {
  72. $postStr = file_get_contents('php://input');
  73. if($postStr)
  74. {
  75. $this->_receive = (array)simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
  76. //Log::info(var_export($this->_receive, true) );
  77. }
  78. return $this;
  79. }
  80. /**
  81. * Get messages sent from WeChat server
  82. */
  83. public function getRevData()
  84. {
  85. return $this->_receive;
  86. }
  87. /**
  88. * Get receiver
  89. */
  90. public function getRevTo()
  91. {
  92. return isset($this->_receive['ToUserName']) ? $this->_receive['ToUserName'] : false;
  93. }
  94. /**
  95. * Get the message sender (an OpenID)
  96. */
  97. public function getRevFrom()
  98. {
  99. return isset($this->_receive['FromUserName']) ? $this->_receive['FromUserName'] : false;
  100. }
  101. /* *
  102. * Get the creation time of the received message (integer type)
  103. */
  104. public function getRevCTime()
  105. {
  106. return isset($this->_receive['CreateTime']) ? $this->_receive['CreateTime'] : false;
  107. }
  108. /**
  109. * Get the received message type (text, image, voice, video, location, link, event)
  110. */
  111. public function getRevType()
  112. {
  113. return isset($this->_receive['MsgType']) ? $this->_receive['MsgType'] : false;
  114. }
  115. /**
  116. * Get the received message number
  117. */
  118. public function getRevId()
  119. {
  120. return isset($this->_receive['MsgId']) ? $this->_receive['MsgId'] : false;
  121. }
  122. /**
  123. * Get the received message text
  124. * Through the speech recognition interface, the voice sent by the user will also give the text content recognized by the speech recognition.(You need to apply for the advanced interface permission of the service account)
  125. */
  126. public function getRevText()
  127. {
  128. if(isset($this->_receive['Content'])) return trim($this->_receive[' Content']);
  129. elseif(isset($this->_receive['Recognition'])) return trim($this->_receive['Recognition']);
  130. else return false;
  131. }
  132. / **
  133. * Get and receive picture messages
  134. */
  135. public function getRevImage()
  136. {
  137. if(isset($this->_receive['PicUrl'])){
  138. return array(
  139. 'picUrl' => $this-> _receive['PicUrl'], //Picture link
  140. 'mediaId' => $this->_receive['MediaId'] //Picture message media id, you can call the multimedia file download interface to pull the data. }
  141. return false;
  142. }
  143. /**
  144. * Get and receive voice messages
  145. */
  146. public function getRevVoice()
  147. {
  148. if(isset($this->_receive['MediaId'])){
  149. return array(
  150. 'mediaId' => $this->_receive['MediaId'], //Voice message media id, you can call the multimedia file download interface to pull data.
  151. 'format' => $this->_receive[' Format'] //Voice format, such as amr, speex, etc.
  152. );
  153. }
  154. return false;
  155. }
  156. /**
  157. *Get to receive video messages
  158. */
  159. public function getRevVideo()
  160. {
  161. if(isset($this ->_receive['MediaId'])){
  162. return array(
  163. 'mediaId' => $this->_receive['MediaId'], //Video message media id, you can call the multimedia file download interface to pull it data.
  164. 'thumbMediaId' => $this->_receive['ThumbMediaId'] //The media ID of the video message thumbnail, you can call the multimedia file download interface to pull the data.
  165. );
  166. }
  167. return false;
  168. }
  169. /**
  170. * Get the user’s geographical location
  171. */
  172. public function getRevLocation()
  173. {
  174. if(isset($this->_receive['Location_X'])){
  175. return array(
  176. 'locationX' => $this->_receive['Location_X'], //Geographical location dimension
  177. 'locationY' => $this->_receive['Location_Y'], //Geographical location Longitude
  178. 'scale' => $this->_receive['Scale'], //Map zoom size
  179. 'label' => $this->_receive['Label'] //Geographical location information
  180. ) ;
  181. }
  182. //For a public account that has opened a geographical location reporting interface, when a user enters the public account session after following it, a box will pop up asking the user to confirm whether the public account is allowed to use its geographical location.
  183. //The pop-up box only appears once after following it. Users can operate on the official account details page in the future.
  184. elseif(isset($this->_receive['Latitude']))
  185. {
  186. return array(
  187. 'latitude' => $this->_receive['Latitude'], //Geographical location latitude
  188. ' longitude' => $this->_receive['Longitude'], //Geographical location longitude
  189. 'precision' => $this->_receive['Precision'] //Geographical location precision
  190. );
  191. }
  192. return false;
  193. }
  194. /**
  195. * Get receiving link message
  196. */
  197. public function getRevLink()
  198. {
  199. if(isset($this->_receive['Title'])){
  200. return array(
  201. ' title' => $this->_receive['Title'], //Message title
  202. 'description' => $this->_receive['Description'], //Message description
  203. 'url' => ; $this->_receive['Url'] //Message link
  204. );
  205. }
  206. return false;
  207. }
  208. /**
  209. * Get the receiving event type
  210. * Event types such as: subscribe, unsubscribe, click
  211. */
  212. public function getRevEvent()
  213. {
  214. if(isset ($this->_receive['Event']))
  215. {
  216. return array(
  217. 'event' => strtolower($this->_receive['Event']),
  218. 'key'=> isset ($this->_receive['EventKey']) ? $this->_receive['EventKey'] : ''
  219. );
  220. }
  221. return false;
  222. }
  223. /**
  224. * Set reply text message
  225. * @param string $content
  226. * @param string $openid
  227. */
  228. public function text($content='')
  229. {
  230. $textTpl = "
  231. < ;![CDATA[%s]]>
  232. %s
  233. ";
  234. $this->_reply = sprintf($textTpl,
  235. $this->getRevFrom (),
  236. $this->getRevTo(),
  237. Date::getTimeStamp(),
  238. 'text',
  239. $content
  240. );
  241. return $this;
  242. }
  243. /**
  244. * Set reply music information
  245. * @param string $title
  246. * @param string $desc
  247. * @param string $musicurl
  248. * @param string $hgmusicurl
  249. */
  250. public function music($title, $desc, $musicurl, $hgmusicurl='')
  251. {
  252. $textTpl = '
  253. < /ToUserName>
  254. %s
  255. <![CDATA[%s]]>
  256. ';
  257. //
  258. $this->_reply = sprintf( $textTpl,
  259. $this->getRevFrom(),
  260. $this->getRevTo(),
  261. Date::getTimeStamp(),
  262. 'music',
  263. $title,
  264. $desc,
  265. $musicurl,
  266. $ hgmusicurl
  267. );
  268. return $this;
  269. }
  270. /**
  271. * Reply to text message
  272. * @param array
  273. */
  274. public function news($data)
  275. {
  276. $count = count($data);
  277. $subText = '';
  278. if($count > 0)
  279. {
  280. foreach($data as $v)
  281. {
  282. $tmpText = '
  283. <![CDATA[%s]]></ Title> </li> <li> <Description><![CDATA[%s]]></Description></li> <li> <PicUrl><![CDATA[%s]]></PicUrl></li> <li> <Url> ;<![CDATA[%s]]></Url></li> <li> </item>';</li> <li> </li> <li> $subText .= sprintf(</li> <li> $tmpText, $v['title'], </li> <li> isset($ v['description']) ? $v['description'] : '', </li> <li> isset($v['picUrl']) ? $v['picUrl'] : '', </li> <li> isset($v['url ']) ? $v['url'] : ''</li> <li> );</li> <li> }</li> <li> }</li> <li> </li> <li> $textTpl = '<xml></li> <li> <ToUserName><![CDATA[%s]]></ToUserName></li> <li> <FromUserName><![CDATA[%s]]></FromUserName></li> <li> <CreateTime><![CDATA[%s]]></CreateTime></li> <li> <MsgType><![CDATA[news]]></MsgType></li> <li> <ArticleCount><![CDATA[%d]]></ArticleCount></li> <li> <Articles>%s</Articles></li> <li> </xml>';</li> <li> </li> <li> $this->_reply = sprintf(</li> <li> $textTpl, </li> <li> $this->getRevFrom(), </li> <li> $this->getRevTo(), </li> <li> Date::getTimeStamp(), </li> <li> $count, </li> <li> $subText</li> <li> );</li> <li> return $this;</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * Reply message </li> <li> * @param array $msg</li> <li> * @param bool $return</li> <li>*/</li> <li> public function reply()</li> <li> {</li> <li> header('Content-Type:text/xml');</li> <li> echo $this->_reply;</li> <li> exit;</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * Custom menu creation </li> <li> * @param array menu data </li> <li>*/</li> <li> public function createMenu($data)</li> <li> {</li> <li> if(!$this->access_token && !$this->checkAuth()) return false;</li> <li> </li> <li> $result = curlRequest(self::API_URL_PREFIX.self::MENU_CREATE_URL.'access_token='.$this->access_token, $this->jsonEncode($data), 'post');</li> <li> if($result)</li> <li> {</li> <li> $jsonArr = json_decode($result, true);</li> <li> if(!$jsonArr || (isset($jsonArr['errcode']) && $jsonArr['errcode'] > 0)) $this->error($jsonArr);</li> <li> else return true;</li> <li> }</li> <li> </li> <li> return false;</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> *Customized menu query</li> <li>*/</li> <li> public function getMenu()</li> <li> {</li> <li> if(!$this->access_token && !$this->checkAuth()) return false;</li> <li> </li> <li> $result = curlRequest(self::API_URL_PREFIX.self::MENU_GET_URL.'access_token='.$this->access_token);</li> <li> if($result)</li> <li> {</li> <li> $jsonArr = json_decode($result, true);</li> <li> if(!$jsonArr || (isset($jsonArr['errcode']) && $jsonArr['errcode'] > 0)) $this->error($jsonArr);</li> <li> else return $jsonArr;</li> <li> }</li> <li> </li> <li> return false;</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> *Custom menu deleted</li> <li>*/</li> <li> public function deleteMenu()</li> <li> {</li> <li> if(!$this->access_token && !$this->checkAuth()) return false;</li> <li> </li> <li> $result = curlRequest(self::API_URL_PREFIX.self::MENU_DELETE_URL.'access_token='.$this->access_token);</li> <li> if($result)</li> <li> {</li> <li> $jsonArr = json_decode($result, true);</li> <li> if(!$jsonArr || (isset($jsonArr['errcode']) && $jsonArr['errcode'] > 0)) $this->error($jsonArr);</li> <li> else return true;</li> <li> }</li> <li> </li> <li> return false;</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * Get basic user information </li> <li> * @param string $openid Identification of ordinary users, unique to the current public account </li> <li>*/</li> <li> public function getUserInfo($openid)</li> <li> {</li> <li> if(!$this->access_token && !$this->checkAuth()) return false;</li> <li> </li> <li> $result = curlRequest(self::API_URL_PREFIX.self::USER_INFO_URL.'access_token='.$this->access_token.'&openid='.$openid);</li> <li> if($result)</li> <li> {</li> <li> $jsonArr = json_decode($result, true);</li> <li> if(!$jsonArr || (isset($jsonArr['errcode']) && $jsonArr['errcode'] > 0)) $this->error($jsonArr);</li> <li> else return $jsonArr;</li> <li> }</li> <li> </li> <li> return false;</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * Get the follower list </li> <li> * @param string $next_openid The first OPENID to pull, if not filled in, it will start pulling from the beginning by default </li> <li>*/</li> <li> public function getUserList($next_openid='')</li> <li> {</li> <li> if(!$this->access_token && !$this->checkAuth()) return false;</li> <li> </li> <li> $result = curlRequest(self::API_URL_PREFIX.self::USER_GET_URL.'access_token='.$this->access_token.'&next_openid='.$next_openid);</li> <li> if($result)</li> <li> {</li> <li> $jsonArr = json_decode($result, true);</li> <li> if(!$jsonArr || (isset($jsonArr['errcode']) && $jsonArr['errcode'] > 0)) $this->error($jsonArr);</li> <li> else return $jsonArr;</li> <li> }</li> <li> </li> <li> return false;</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * Query grouping </li> <li>*/</li> <li> public function getGroup()</li> <li> {</li> <li> if(!$this->access_token && !$this->checkAuth()) return false;</li> <li> </li> <li> $result = curlRequest(self::API_URL_PREFIX.self::GROUPS_GET_URL.'access_token='.$this->access_token);</li> <li> if($result)</li> <li> {</li> <li> $jsonArr = json_decode($result, true);</li> <li> if(!$jsonArr || (isset($jsonArr['errcode']) && $jsonArr['errcode'] > 0)) $this->error($jsonArr);</li> <li> else return $jsonArr;</li> <li> }</li> <li> </li> <li> return false;</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * Create a group </li> <li> * @param string $name Group name (within 30 characters) </li> <li>*/</li> <li> public function createGroup($name)</li> <li> {</li> <li> if(!$this->access_token && !$this->checkAuth()) return false;</li> <li> $data = array('group' => array('name' => $name));</li> <li> $result = curlRequest(self::API_URL_PREFIX.self::GROUPS_CREATE_URL.'access_token='.$this->access_token, $this->jsonEncode($data), 'post');</li> <li> if($result)</li> <li> {</li> <li> $jsonArr = json_decode($result, true);</li> <li> if(!$jsonArr || (isset($jsonArr['errcode']) && $jsonArr['errcode'] > 0)) $this->error($jsonArr);</li> <li> else return true;</li> <li> }</li> <li> </li> <li> return false;</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * Modify the group name </li> <li> * @param int $id Group id, assigned by WeChat </li> <li> * @param string $name Group name (within 30 characters) </li> <li>*/</li> <li> public function updateGroup($id, $name)</li> <li> {</li> <li> if(!$this->access_token && !$this->checkAuth()) return false;</li> <li> </li> <li> $data = array('group' => array('id' => $id, 'name' => $name));</li> <li> $result = curlRequest(self::API_URL_PREFIX.self::GROUPS_UPDATE_URL.'access_token='.$this->access_token, $this->jsonEncode($data), 'post');</li> <li> if($result)</li> <li> {</li> <li> $jsonArr = json_decode($result, true);</li> <li> if(!$jsonArr || (isset($jsonArr['errcode']) && $jsonArr['errcode'] > 0)) $this->error($jsonArr);</li> <li> else return true;</li> <li> }</li> <li> </li> <li> return false;</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * Mobile user group</li> <li> * </li> <li> * @param string $openid User unique identifier</li> <li> * @param int $to_groupid Group id</li> <li>*/</li> <li> public function updateGroupMembers($openid, $to_groupid)</li> <li> {</li> <li> if(!$this->access_token && !$this->checkAuth()) return false;</li> <li> </li> <li> $data = array('openid' => $openid, 'to_groupid' => $to_groupid);</li> <li> $result = curlRequest(self::API_URL_PREFIX.self::GROUPS_MEMBERS_UPDATE_URL.'access_token='.$this->access_token, $this->jsonEncode($data), 'post');</li> <li> if($result)</li> <li> {</li> <li> $jsonArr = json_decode($result, true);</li> <li> if(!$jsonArr || (isset($jsonArr['errcode']) && $jsonArr['errcode'] > 0)) $this->error($jsonArr);</li> <li> else return true;</li> <li> }</li> <li> </li> <li> return false;</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * 发送客服消息</li> <li> * 当用户主动发消息给公众号的时候(包括发送信息、点击自定义菜单clike事件、订阅事件、扫描二维码事件、支付成功事件、用户维权),</li> <li> * 微信将会把消息数据推送给开发者,开发者在一段时间内(目前为24小时)可以调用客服消息接口,通过POST一个JSON数据包来发送消息给普通用户,在24小时内不限制发送次数。</li> <li> * 此接口主要用于客服等有人工消息处理环节的功能,方便开发者为用户提供更加优质的服务。</li> <li> * </li> <li> * @param string $touser ordinary user openid</li> <li> */</li> <li> public function sendCustomMessage($touser, $data, $msgType = 'text')</li> <li> {</li> <li> $arr = array();</li> <li> $arr['touser' ] = $touser;</li> <li> $arr['msgtype'] = $msgType;</li> <li> switch ($msgType)</li> <li> {</li> <li> case 'text': // Send text message</li> <li> $arr['text']['content'] = $data; </li> <li> break;</li> <li> </li> <li> case 'image': // Send a picture message </li> <li> $arr['image']['media_id'] = $data;</li> <li> break;</li> <li> </li> <li> case 'voice': // Send a voice message </li> <li> $arr['voice']['media_id'] = $data;</li> <li> break;</li> <li> </li> <li> case 'video': // Send video message </li> <li> $arr['video']['media_id'] = $data[' media_id']; // The media ID of the video sent</li> <li> $arr['video']['thumb_media_id'] = $data['thumb_media_id']; // The media ID of the video thumbnail</li> <li> break;</li> <li> </li> <li> case 'music ': //Send music message</li> <li> $arr['music']['title'] = $data['title'];//Music title</li> <li> $arr['music']['description'] = $data[ 'description'];//Music description</li> <li> $arr['music']['musicurl'] = $data['musicurl'];//Music link</li> <li> $arr['music']['hqmusicurl'] = $ data['hqmusicurl'];// High-quality music link, the wifi environment will give priority to using this link to play music</li> <li> $arr['music']['thumb_media_id'] = $data['title'];// Thumbnail media ID</li> <li> break;</li> <li> </li> <li> case 'news': //Send graphic message</li> <li> $arr['news']['articles'] = $data; // title, description, url, picurl</li> <li> break;</li> <li> } </li> <li> </li> <li> if(!$this->access_token && !$this->checkAuth()) return false;</li> <li> </li> <li> $result = curlRequest(self::API_URL_PREFIX.self::MESSAGE_CUSTOM_SEND_URL.'access_token='.$this-> access_token, $this->jsonEncode($arr), 'post');</li> <li> if($result)</li> <li> {</li> <li> $jsonArr = json_decode($result, true);</li> <li> if(!$jsonArr || (isset($ jsonArr['errcode']) && $jsonArr['errcode'] > 0)) $this->error($jsonArr);</li> <li> else return true;</li> <li> }</li> <li> </li> <li> return false;</li> <li> }</li> <li> </li> <li> </li> <li> </li> <li> / **</li> <li> * Get access_token</li> <li>*/</li> <li> public function checkAuth()</li> <li> {</li> <li> </li> <li> // Get access_token from cache</li> <li> $cache_flag = 'weixin_access_token';</li> <li> $access_token = cache($cache_flag);</li> <li> if($access_token) </li> <li> { </li> <li> $this->access_token = $access_token;</li> <li> return true;</li> <li> }</li> <li> </li> <li> // Request the WeChat server to obtain access_token </li> <li> $result = curlRequest(self::API_URL_PREFIX.self::AUTH_URL.'appid='.$this- >appid.'&secret='.$this->appsecret);</li> <li> if($result)</li> <li> {</li> <li> $jsonArr = json_decode($result, true);</li> <li> if(!$jsonArr || (isset($jsonArr ['errcode']) && $jsonArr['errcode'] > 0))</li> <li> {</li> <li> $this->error($jsonArr);</li> <li> }</li> <li> else</li> <li> {</li> <li> $this->access_token = $jsonArr[ 'access_token'];</li> <li> $expire = isset($jsonArr['expires_in']) ? intval($jsonArr['expires_in'])-100 : 3600;</li> <li> // Save access_token to cache</li> <li> cache($cache_flag, $this->access_token, $expire, Cache::FILE); </li> <li> return true;</li> <li> }</li> <li> }</li> <li> return false;</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * WeChat oauth login->Step 1: User consent Authorize, get code</li> <li> * Application authorization scope, snsapi_base (the authorization page will not pop up, jump directly, only the user's openid can be obtained), </li> <li> * snsapi_userinfo (the authorization page will pop up, you can get the nickname, gender, and location through openid). Moreover, even if you are not following the user, you can still obtain their information as long as the user authorizes it)</li> <li> * Open the link directly on WeChat, you do not need to fill in this parameter.When doing page 302 redirection, you must bring this parameter</li> <li> * </li> <li> * @param string $redirect_uri The callback link address for redirection after authorization</li> <li> * @param string $scope Application authorization scope 0 is snsapi_base, 1 is snsapi_userinfo</li> <li> * @param string $state will bring the state parameter after redirection. Developers can fill in any parameter value</li> <li> */</li> <li> public function redirectGetOauthCode($redirect_uri, $scope=0, $state='')</li> <li> {</li> <li> $scope = ($scope == 0) ? 'snsapi_base' : 'snsapi_userinfo';</li> <li> $url = self::CONNECT_OAUTH_AUTHORIZE_URL.'appid='.$this->appid.'&redirect_uri='.urlencode($redirect_uri).'&response_type=code&scope= '.$scope.'&state='.$state.'#wechat_redirect';</li> <li> redirect($url);</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * WeChat oauth login-> Step 2: Exchange the code for webpage authorization access_token</li> <li> * </li> <li> * @param string $code</li> <li>*/</li> <li> public function getSnsAccessToken($code)</li> <li> {</li> <li> $ result = curlRequest(self::SNS_OAUTH_ACCESS_TOKEN_URL.'appid='.$this->appid.'&secret='.$this->appsecret.'&code='.$code.'&grant_type=authorization_code');</li> <li> if ($result)</li> <li> {</li> <li> $jsonArr = json_decode($result, true);</li> <li> if(!$jsonArr || (isset($jsonArr['errcode']) && $jsonArr['errcode'] > 0)) $this->error($jsonArr);</li> <li> else return $jsonArr;</li> <li> }</li> <li> </li> <li> return false;</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * WeChat oauth login-> Step 3: Refresh access_token (if necessary) </li> <li> * Since access_token has a short validity period, when the access_token times out, you can use refresh_token to refresh, </li> <li> * refresh_token has a longer validity period (7 days , 30 days, 60 days, 90 days), when refresh_token expires, the user needs to re-authorize. </li> <li> * </li> <li> * @param string $refresh_token Fill in the refresh_token parameter obtained through access_token</li> <li>*/</li> <li> public function refershToken($refresh_token)</li> <li> {</li> <li> $result = curlRequest(self::SNS_OAUTH_REFRESH_TOKEN_URL.'appid='.$this->appid.'&grant_type=refresh_token&refresh_token='.$refresh_token);</li> <li> if($result)</li> <li> {</li> <li> $jsonArr = json_decode($result, true) ;</li> <li> if(!$jsonArr || (isset($jsonArr['errcode']) && $jsonArr['errcode'] > 0)) $this->error($jsonArr);</li> <li> else return $jsonArr; </li> <li> }</li> <li> </li> <li> return false;</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * WeChat oauth login-> Step 4: Pull user information (need to have scope snsapi_userinfo)</li> <li> * If the web page authorization scope is snsapi_userinfo, the developer can now pull user information through access_token and openid. </li> <li> * </li> <li> * @param string $access_token Web page authorization interface call certificate, note: this access_token is different from the basic supported access_token</li> <li> * @param string $openid The unique identifier of the user</li> <li>*/</li> <li> public function getSnsUserInfo($access_token, $openid)</li> <li> {</li> <li> $result = curlRequest(self::SNS_USERINFO_URL.'access_token='.$ access_token.'&openid='.$openid);</li> <li> if($result)</li> <li> {</li> <li> $jsonArr = json_decode($result, true);</li> <li> if(!$jsonArr || (isset($jsonArr['errcode']) && $jsonArr['errcode'] > 0)) $this->error($jsonArr);</li> <li> else return $jsonArr;</li> <li> }</li> <li> </li> <li> return false;</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * Create a QR code ticket</li> <li> * Each time you create a QR code ticket, you need to provide a parameter (scene_id) set by the developer. The process of creating a QR code ticket for temporary QR codes and permanent QR codes is introduced respectively. </li> <li> * </li> <li> * @param int $scene_id Scene value ID, 32-bit integer for temporary QR code, maximum value is 1000 for permanent QR code</li> <li> * @param int $type QR code type, 0 is temporary, 1 It is permanent</li> <li> * @param int $expire The validity time of this QR code, in seconds. The maximum number does not exceed 1800. </li> <li>*/ </li> <li> public function createQrcode($scene_id, $type=0, $expire=1800)</li> <li> {</li> <li> if(!$this->access_token && !$this->checkAuth()) return false;</li> <li> </li> <li> $data = array ();</li> <li> $data['action_info'] = array('scene' => array('scene_id' => $scene_id));</li> <li> $data['action_name'] = ($type == 0 ? ' QR_SCENE' : 'QR_LIMIT_SCENE');</li> <li> if($type == 0) $data['expire_seconds'] = $expire;</li> <li> </li> <li> $result = curlRequest(self::API_URL_PREFIX.self::QRCODE_CREATE_URL.'access_token='. $this->access_token, $this->jsonEncode($data), 'post');</li> <li> if($result)</li> <li> {</li> <li> $jsonArr = json_decode($result, true);</li> <li> if(!$jsonArr | | (isset($jsonArr['errcode']) && $jsonArr['errcode'] > 0)) $this->error($jsonArr);</li> <li> else return $jsonArr;</li> <li> }</li> <li> </li> <li> return false;</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * Exchange tickets for QR codes</li> <li> * After obtaining a QR code ticket, developers can exchange the ticket for a QR code image. Please note that this interface can be called without logging in. </li> <li> * Reminder: Remember to UrlEncode TICKET</li> <li> * When the ticket is correct, the http return code is 200, which is a picture and can be displayed or downloaded directly. </li> <li> * HTTP error code 404 will be returned in error situations (such as invalid ticket).</li> <li> * </li> <li> * @param string $ticket</li> <li> */</li> <li> public function getQrcodeUrl($ticket)</li> <li> {</li> <li> return self::SHOW_QRCODE_URL.'ticket='.urlencode($ticket);</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * Record the error log generated by the interface</li> <li>*/</li> <li> public function error($data)</li> <li> {</li> <li> $this->errCode = $data['errcode'];</li> <li> $this->errMsg = $data['errmsg'];</li> <li> Log::info('WEIXIN API errcode:['.$this->errCode.'] errmsg:['.$this->errMsg.']');</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * Convert Chinese in the array into json data</li> <li> * @param array $arr</li> <li>*/</li> <li> public function jsonEncode($arr) {</li> <li> $parts = array ();</li> <li> $is_list = false;</li> <li> //Find out if the given array is a numerical array</li> <li> $keys = array_keys ( $arr );</li> <li> $max_length = count ( $arr ) - 1;</li> <li> if (($keys [0] === 0) && ($keys [$max_length] === $max_length )) { //See if the first key is 0 and last key is length - 1</li> <li> $is_list = true;</li> <li> for($i = 0; $i < count ( $keys ); $i ++) { //See if each key correspondes to its position<li> if ($i != $keys [$i]) { //A key fails at position check.<li> $is_list = false; //It is an associative array.<li> break;<li> }<li> }<li> }<li> foreach ( $arr as $key => $value ) {</li> <li> if (is_array ( $value )) { //Custom handling for arrays</li> <li> if ($is_list)</li> <li> $parts [] = $this->jsonEncode ( $value ); /* :RECURSION: */</li> <li> else</li> <li> $parts [] = '"' . $key . '":' . $this->jsonEncode ( $value ); /* :RECURSION: */</li> <li> } else {</li> <li> $str = '';</li> <li> if (! $is_list)</li> <li> $str = '"' . $key . '":';</li> <li> //Custom handling for multiple data types</li> <li> if (is_numeric ( $value ) && $value<2000000000)<li> $str .= $value; //Numbers<li> elseif ($value === false)<li> $str .= 'false'; //The booleans<li> elseif ($value === true)<li> $str .= 'true';<li> else<li> $str .= '"' . addslashes ( $value ) . '"'; //All other things<li> // :TODO: Is there any more datatype we should be in the lookout for? (Object?)<li> $parts [] = $str;<li> }<li> }<li> $json = implode ( ',', $parts );<li> if ($is_list)<li> return '[' . $json . ']'; //Return numerical JSON<li> return '{' . $json . '}'; //Return associative JSON<li> }<li><li> <li> /**<li> * Verify signature <li>*/<li> public function checkSignature()<li> {<li> $signature = HttpRequest::getGet('signature');<li> $timestamp = HttpRequest::getGet('timestamp');<li> $nonce = HttpRequest::getGet('nonce');<li> <li> $token = $this->token;</li> <li> $tmpArr = array($token, $timestamp, $nonce);</li> <li> sort($tmpArr);</li> <li> $tmpStr = implode($tmpArr);</li> <li> $tmpStr = sha1($tmpStr);</li> <li> </li> <li> return ($tmpStr == $signature ? true : false);</li> <li> }</li> <li> </li> <li> </li> <li> /**</li> <li> * Verify whether the token is valid</li> <li>*/</li> <li> public function valid()</li> <li> {</li> <li> if($this->checkSignature()) exit(HttpRequest::getGet('echostr'));</li> <li> }</li> <li> </li> <li>}</li> </ol></div> <em onclick="copycode($('code_ZWw'));">复制代码</em> </div> </td></tr></table> <div id="comment_51454" class="cm"> </div> <div id="post_rate_div_51454"></div> <br><br> </div> </div> <div style="height: 25px;"> <div class="wzconBq" style="display: inline-flex;"> <span>Related labels:</span> <div class="wzcbqd"> <a onclick="hits_log(2,'www',this);" href-data="https://www.php.cn/search?word=基于eaglephp框架v27开发的微信50最新最全的api接口" target="_blank">基于EaglePHP框架v2.7开发的微信5.0最新最全的API接口</a> </div> </div> <div style="display: inline-flex;float: right; color:#333333;">source:php.cn</div> </div> <div class="wzconOtherwz"> <a href="https://www.php.cn/faq/314409.html" title="WeChat scan login"> <span>Previous article:WeChat scan login</span> </a> <a href="https://www.php.cn/faq/314425.html" title="Weight calculation, with slight modifications, can also be used for word segmentation, word frequency statistics, full text and spam detection, etc."> <span>Next article:Weight calculation, with slight modifications, can also be used for word segmentation, word frequency statistics, full text and spam detection, etc.</span> </a> </div> <div class="wzconShengming"> <div class="bzsmdiv">Statement of this Website</div> <div>The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn</div> </div> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5902227090019525" data-ad-slot="2507867629"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <div class="wzconZzwz"> <div class="wzconZzwztitle">Latest Articles by Author</div> <ul> <li> <div class="wzczzwzli"> <span class="layui-badge-dots"></span> <a target="_blank" href="https://www.php.cn/faq/1796639331.html">What is a NullPointerException, and how do I fix it?</a> </div> <div>2024-10-22 09:46:29</div> </li> <li> <div class="wzczzwzli"> <span class="layui-badge-dots"></span> <a target="_blank" href="https://www.php.cn/faq/1796629482.html">From Novice to Coder: Your Journey Begins with C Fundamentals</a> </div> <div>2024-10-13 13:53:41</div> </li> <li> <div class="wzczzwzli"> <span class="layui-badge-dots"></span> <a target="_blank" href="https://www.php.cn/faq/1796628545.html">Unlocking Web Development with PHP: A Beginner's Guide</a> </div> <div>2024-10-12 12:15:51</div> </li> <li> <div class="wzczzwzli"> <span class="layui-badge-dots"></span> <a target="_blank" href="https://www.php.cn/faq/1796627928.html">Demystifying C: A Clear and Simple Path for New Programmers</a> </div> <div>2024-10-11 22:47:31</div> </li> <li> <div class="wzczzwzli"> <span class="layui-badge-dots"></span> <a target="_blank" href="https://www.php.cn/faq/1796627806.html">Unlock Your Coding Potential: C Programming for Absolute Beginners</a> </div> <div>2024-10-11 19:36:51</div> </li> <li> <div class="wzczzwzli"> <span class="layui-badge-dots"></span> <a target="_blank" href="https://www.php.cn/faq/1796627670.html">Unleash Your Inner Programmer: C for Absolute Beginners</a> </div> <div>2024-10-11 15:50:41</div> </li> <li> <div class="wzczzwzli"> <span class="layui-badge-dots"></span> <a target="_blank" href="https://www.php.cn/faq/1796627643.html">Automate Your Life with C: Scripts and Tools for Beginners</a> </div> <div>2024-10-11 15:07:41</div> </li> <li> <div class="wzczzwzli"> <span class="layui-badge-dots"></span> <a target="_blank" href="https://www.php.cn/faq/1796627620.html">PHP Made Easy: Your First Steps in Web Development</a> </div> <div>2024-10-11 14:21:21</div> </li> <li> <div class="wzczzwzli"> <span class="layui-badge-dots"></span> <a target="_blank" href="https://www.php.cn/faq/1796627574.html">Build Anything with Python: A Beginner's Guide to Unleashing Your Creativity</a> </div> <div>2024-10-11 12:59:11</div> </li> <li> <div class="wzczzwzli"> <span class="layui-badge-dots"></span> <a target="_blank" href="https://www.php.cn/faq/1796627539.html">The Key to Coding: Unlocking the Power of Python for Beginners</a> </div> <div>2024-10-11 12:17:31</div> </li> </ul> </div> <div class="wzconZzwz"> <div class="wzconZzwztitle">Latest Issues</div> <div class="wdsyContent"> <div class="wdsyConDiv flexRow wdsyConDiv1"> <div class="wdcdContent flexColumn"> <a href="https://www.php.cn/wenda/176411.html" target="_blank" title="function_exists() cannot determine the custom function" class="wdcdcTitle">function_exists() cannot determine the custom function</a> <a href="https://www.php.cn/wenda/176411.html" class="wdcdcCons">Function test () {return true;} if (function_exists ('test')) {echo "test is function...</a> <div class="wdcdcInfo flexRow"> <div class="wdcdcileft"> <span class="wdcdciSpan"> From 2024-04-29 11:01:01</span> </div> <div class="wdcdciright flexRow"> <div class="wdcdcirdz flexRow ira"> <b class="wdcdcirdzi"></b>0 </div> <div class="wdcdcirpl flexRow ira"><b class="wdcdcirpli"></b>3</div> <div class="wdcdcirwatch flexRow ira"><b class="wdcdcirwatchi"></b>2206</div> </div> </div> </div> </div> <div class="wdsyConLine wdsyConLine2"></div> <div class="wdsyConDiv flexRow wdsyConDiv1"> <div class="wdcdContent flexColumn"> <a href="https://www.php.cn/wenda/176410.html" target="_blank" title="How to display the mobile version of Google Chrome" class="wdcdcTitle">How to display the mobile version of Google Chrome</a> <a href="https://www.php.cn/wenda/176410.html" class="wdcdcCons">Hello teacher, how can I change Google Chrome into a mobile version?</a> <div class="wdcdcInfo flexRow"> <div class="wdcdcileft"> <span class="wdcdciSpan"> From 2024-04-23 00:22:19</span> </div> <div class="wdcdciright flexRow"> <div class="wdcdcirdz flexRow ira"> <b class="wdcdcirdzi"></b>0 </div> <div class="wdcdcirpl flexRow ira"><b class="wdcdcirpli"></b>11</div> <div class="wdcdcirwatch flexRow ira"><b class="wdcdcirwatchi"></b>2358</div> </div> </div> </div> </div> <div class="wdsyConLine wdsyConLine2"></div> <div class="wdsyConDiv flexRow wdsyConDiv1"> <div class="wdcdContent flexColumn"> <a href="https://www.php.cn/wenda/176407.html" target="_blank" title="The child window operates the parent window, but the output does not respond." class="wdcdcTitle">The child window operates the parent window, but the output does not respond.</a> <a href="https://www.php.cn/wenda/176407.html" class="wdcdcCons">The first two sentences are executable, but the last sentence cannot be implemented.</a> <div class="wdcdcInfo flexRow"> <div class="wdcdcileft"> <span class="wdcdciSpan"> From 2024-04-19 15:37:47</span> </div> <div class="wdcdciright flexRow"> <div class="wdcdcirdz flexRow ira"> <b class="wdcdcirdzi"></b>0 </div> <div class="wdcdcirpl flexRow ira"><b class="wdcdcirpli"></b>1</div> <div class="wdcdcirwatch flexRow ira"><b class="wdcdcirwatchi"></b>1973</div> </div> </div> </div> </div> <div class="wdsyConLine wdsyConLine2"></div> <div class="wdsyConDiv flexRow wdsyConDiv1"> <div class="wdcdContent flexColumn"> <a href="https://www.php.cn/wenda/176406.html" target="_blank" title="There is no output in the parent window" class="wdcdcTitle">There is no output in the parent window</a> <a href="https://www.php.cn/wenda/176406.html" class="wdcdcCons">document.onclick = function(){ window.opener.document.write('I am the output of the child ...</a> <div class="wdcdcInfo flexRow"> <div class="wdcdcileft"> <span class="wdcdciSpan"> From 2024-04-18 23:52:34</span> </div> <div class="wdcdciright flexRow"> <div class="wdcdcirdz flexRow ira"> <b class="wdcdcirdzi"></b>0 </div> <div class="wdcdcirpl flexRow ira"><b class="wdcdcirpli"></b>1</div> <div class="wdcdcirwatch flexRow ira"><b class="wdcdcirwatchi"></b>1857</div> </div> </div> </div> </div> <div class="wdsyConLine wdsyConLine2"></div> <div class="wdsyConDiv flexRow wdsyConDiv1"> <div class="wdcdContent flexColumn"> <a href="https://www.php.cn/wenda/176405.html" target="_blank" title="Where is the courseware about CSS mind mapping?" class="wdcdcTitle">Where is the courseware about CSS mind mapping?</a> <a href="https://www.php.cn/wenda/176405.html" class="wdcdcCons">Courseware</a> <div class="wdcdcInfo flexRow"> <div class="wdcdcileft"> <span class="wdcdciSpan"> From 2024-04-16 10:10:18</span> </div> <div class="wdcdciright flexRow"> <div class="wdcdcirdz flexRow ira"> <b class="wdcdcirdzi"></b>0 </div> <div class="wdcdcirpl flexRow ira"><b class="wdcdcirpli"></b>0</div> <div class="wdcdcirwatch flexRow ira"><b class="wdcdcirwatchi"></b>1922</div> </div> </div> </div> </div> <div class="wdsyConLine wdsyConLine2"></div> </div> </div> <div class="wzconZt" > <div class="wzczt-title"> <div>Related Topics</div> <a href="https://www.php.cn/faq/zt" target="_blank">More> </a> </div> <div class="wzcttlist"> <ul> <li class="ul-li"> <a target="_blank" href="https://www.php.cn/faq/kdrjfwq"><img src="https://img.php.cn/upload/subject/202407/22/2024072213562155602.jpg?x-oss-process=image/resize,m_fill,h_145,w_220" alt="How to connect broadband to server" /> </a> <a target="_blank" href="https://www.php.cn/faq/kdrjfwq" class="title-a-spanl" title="How to connect broadband to server"><span>How to connect broadband to server</span> </a> </li> <li class="ul-li"> <a target="_blank" href="https://www.php.cn/faq/dnxnnczmsz"><img src="https://img.php.cn/upload/subject/202407/22/2024072214060649564.jpg?x-oss-process=image/resize,m_fill,h_145,w_220" alt="How to set up computer virtual memory" /> </a> <a target="_blank" href="https://www.php.cn/faq/dnxnnczmsz" class="title-a-spanl" title="How to set up computer virtual memory"><span>How to set up computer virtual memory</span> </a> </li> <li class="ul-li"> <a target="_blank" href="https://www.php.cn/faq/dnyjjcrjpmtj"><img src="https://img.php.cn/upload/subject/202407/22/2024072212091993794.jpg?x-oss-process=image/resize,m_fill,h_145,w_220" alt="Recommended computer hardware testing software rankings" /> </a> <a target="_blank" href="https://www.php.cn/faq/dnyjjcrjpmtj" class="title-a-spanl" title="Recommended computer hardware testing software rankings"><span>Recommended computer hardware testing software rankings</span> </a> </li> <li class="ul-li"> <a target="_blank" href="https://www.php.cn/faq/nullpointerex"><img src="https://img.php.cn/upload/subject/202407/22/2024072214075044480.jpg?x-oss-process=image/resize,m_fill,h_145,w_220" alt="nullpointerexception exception" /> </a> <a target="_blank" href="https://www.php.cn/faq/nullpointerex" class="title-a-spanl" title="nullpointerexception exception"><span>nullpointerexception exception</span> </a> </li> <li class="ul-li"> <a target="_blank" href="https://www.php.cn/faq/smsmfkj"><img src="https://img.php.cn/upload/subject/202407/22/2024072212080072248.jpg?x-oss-process=image/resize,m_fill,h_145,w_220" alt="What is free space" /> </a> <a target="_blank" href="https://www.php.cn/faq/smsmfkj" class="title-a-spanl" title="What is free space"><span>What is free space</span> </a> </li> <li class="ul-li"> <a target="_blank" href="https://www.php.cn/faq/sipfwqdzy"><img src="https://img.php.cn/upload/subject/202407/22/2024072212104026173.jpg?x-oss-process=image/resize,m_fill,h_145,w_220" alt="What is the role of sip server" /> </a> <a target="_blank" href="https://www.php.cn/faq/sipfwqdzy" class="title-a-spanl" title="What is the role of sip server"><span>What is the role of sip server</span> </a> </li> <li class="ul-li"> <a target="_blank" href="https://www.php.cn/faq/pstcqpkjj"><img src="https://img.php.cn/upload/subject/202407/22/2024072214215494580.jpg?x-oss-process=image/resize,m_fill,h_145,w_220" alt="ps exit full screen shortcut key" /> </a> <a target="_blank" href="https://www.php.cn/faq/pstcqpkjj" class="title-a-spanl" title="ps exit full screen shortcut key"><span>ps exit full screen shortcut key</span> </a> </li> <li class="ul-li"> <a target="_blank" href="https://www.php.cn/faq/qlcplj"><img src="https://img.php.cn/upload/subject/202407/22/2024072214303938253.jpg?x-oss-process=image/resize,m_fill,h_145,w_220" alt="cmd command to clean up C drive junk" /> </a> <a target="_blank" href="https://www.php.cn/faq/qlcplj" class="title-a-spanl" title="cmd command to clean up C drive junk"><span>cmd command to clean up C drive junk</span> </a> </li> </ul> </div> </div> </div> </div> <div class="phpwzright"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5902227090019525" data-ad-slot="3653428331" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <div class="wzrOne"> <div class="wzroTitle">Popular Recommendations</div> <div class="wzroList"> <ul> <li> <div class="wzczzwzli"> <span class="layui-badge-dots wzrolr"></span> <a style="height: auto;" title="How to set up hosts on Mac computer (steps with pictures and text)" href="https://www.php.cn/faq/448310.html">How to set up hosts on Mac computer (steps with pictures and text)</a> </div> </li> <li> <div class="wzczzwzli"> <span class="layui-badge-dots wzrolr"></span> <a style="height: auto;" title="Quickly build a simple QQ robot with PHP" href="https://www.php.cn/faq/448391.html">Quickly build a simple QQ robot with PHP</a> </div> </li> <li> <div class="wzczzwzli"> <span class="layui-badge-dots wzrolr"></span> <a style="height: auto;" title="API common signature verification methods (PHP implementation)" href="https://www.php.cn/faq/448286.html">API common signature verification methods (PHP implementation)</a> </div> </li> <li> <div class="wzczzwzli"> <span class="layui-badge-dots wzrolr"></span> <a style="height: auto;" title="Collection of common date and time operations in PHP" href="https://www.php.cn/faq/448309.html">Collection of common date and time operations in PHP</a> </div> </li> <li> <div class="wzczzwzli"> <span class="layui-badge-dots wzrolr"></span> <a style="height: auto;" title="PHP generates graphic verification code (enhanced interference type)" href="https://www.php.cn/faq/448308.html">PHP generates graphic verification code (enhanced interference type)</a> </div> </li> </ul> </div> </div> <script src="https://sw.php.cn/hezuo/cac1399ab368127f9b113b14eb3316d0.js" type="text/javascript"></script> <div class="wzrThree"> <div class="wzrthree-title"> <div>Popular Tutorials</div> <a target="_blank" href="https://www.php.cn/course.html">More> </a> </div> <div class="wzrthreelist swiper2"> <div class="wzrthreeTab swiper-wrapper"> <div class="check tabdiv swiper-slide" data-id="one">Related Tutorials <div></div></div> <div class="tabdiv swiper-slide" data-id="two">Popular Recommendations<div></div></div> <div class="tabdiv swiper-slide" data-id="three">Latest courses<div></div></div> </div> <ul class="one"> <li> <a target="_blank" href="https://www.php.cn/course/812.html" title="The latest ThinkPHP 5.1 world premiere video tutorial (60 days to become a PHP expert online training course)" class="wzrthreelaimg"> <img src="https://img.php.cn/upload/course/000/000/041/620debc3eab3f377.jpg" alt="The latest ThinkPHP 5.1 world premiere video tutorial (60 days to become a PHP expert online training course)"/> </a> <div class="wzrthree-right"> <a target="_blank" title="The latest ThinkPHP 5.1 world premiere video tutorial (60 days to become a PHP expert online training course)" href="https://www.php.cn/course/812.html">The latest ThinkPHP 5.1 world premiere video tutorial (60 days to become a PHP expert online training course)</a> <div class="wzrthreerb"> <div>1422987 <b class="kclbcollectb"></b></div> <div class="courseICollection" data-id="812"> <b class="nofollow small-nocollect"></b> </div> </div> </div> </li> <li> <a target="_blank" href="https://www.php.cn/course/74.html" title="PHP introductory tutorial one: Learn PHP in one week" class="wzrthreelaimg"> <img src="https://img.php.cn/upload/course/000/000/068/6253d1e28ef5c345.png" alt="PHP introductory tutorial one: Learn PHP in one week"/> </a> <div class="wzrthree-right"> <a target="_blank" title="PHP introductory tutorial one: Learn PHP in one week" href="https://www.php.cn/course/74.html">PHP introductory tutorial one: Learn PHP in one week</a> <div class="wzrthreerb"> <div>4268330 <b class="kclbcollectb"></b></div> <div class="courseICollection" data-id="74"> <b class="nofollow small-nocollect"></b> </div> </div> </div> </li> <li> <a target="_blank" href="https://www.php.cn/course/286.html" title="JAVA Beginner's Video Tutorial" class="wzrthreelaimg"> <img src="https://img.php.cn/upload/course/000/000/068/62590a2bacfd9379.png" alt="JAVA Beginner's Video Tutorial"/> </a> <div class="wzrthree-right"> <a target="_blank" title="JAVA Beginner's Video Tutorial" href="https://www.php.cn/course/286.html">JAVA Beginner's Video Tutorial</a> <div class="wzrthreerb"> <div>2533902 <b class="kclbcollectb"></b></div> <div class="courseICollection" data-id="286"> <b class="nofollow small-nocollect"></b> </div> </div> </div> </li> <li> <a target="_blank" href="https://www.php.cn/course/504.html" title="Little Turtle's zero-based introduction to learning Python video tutorial" class="wzrthreelaimg"> <img src="https://img.php.cn/upload/course/000/000/068/62590a67ce3a6655.png" alt="Little Turtle's zero-based introduction to learning Python video tutorial"/> </a> <div class="wzrthree-right"> <a target="_blank" title="Little Turtle's zero-based introduction to learning Python video tutorial" href="https://www.php.cn/course/504.html">Little Turtle's zero-based introduction to learning Python video tutorial</a> <div class="wzrthreerb"> <div>507244 <b class="kclbcollectb"></b></div> <div class="courseICollection" data-id="504"> <b class="nofollow small-nocollect"></b> </div> </div> </div> </li> <li> <a target="_blank" href="https://www.php.cn/course/2.html" title="PHP zero-based introductory tutorial" class="wzrthreelaimg"> <img src="https://img.php.cn/upload/course/000/000/068/6253de27bc161468.png" alt="PHP zero-based introductory tutorial"/> </a> <div class="wzrthree-right"> <a target="_blank" title="PHP zero-based introductory tutorial" href="https://www.php.cn/course/2.html">PHP zero-based introductory tutorial</a> <div class="wzrthreerb"> <div>862380 <b class="kclbcollectb"></b></div> <div class="courseICollection" data-id="2"> <b class="nofollow small-nocollect"></b> </div> </div> </div> </li> </ul> <ul class="two" style="display: none;"> <li> <a target="_blank" href="https://www.php.cn/course/812.html" title="The latest ThinkPHP 5.1 world premiere video tutorial (60 days to become a PHP expert online training course)" class="wzrthreelaimg"> <img src="https://img.php.cn/upload/course/000/000/041/620debc3eab3f377.jpg" alt="The latest ThinkPHP 5.1 world premiere video tutorial (60 days to become a PHP expert online training course)"/> </a> <div class="wzrthree-right"> <a target="_blank" title="The latest ThinkPHP 5.1 world premiere video tutorial (60 days to become a PHP expert online training course)" href="https://www.php.cn/course/812.html">The latest ThinkPHP 5.1 world premiere video tutorial (60 days to become a PHP expert online training course)</a> <div class="wzrthreerb"> <div >1422987 times of learning</div> <div class="courseICollection" data-id="812"> <b class="nofollow small-nocollect"></b> </div> </div> </div> </li> <li> <a target="_blank" href="https://www.php.cn/course/286.html" title="JAVA Beginner's Video Tutorial" class="wzrthreelaimg"> <img src="https://img.php.cn/upload/course/000/000/068/62590a2bacfd9379.png" alt="JAVA Beginner's Video Tutorial"/> </a> <div class="wzrthree-right"> <a target="_blank" title="JAVA Beginner's Video Tutorial" href="https://www.php.cn/course/286.html">JAVA Beginner's Video Tutorial</a> <div class="wzrthreerb"> <div >2533902 times of learning</div> <div class="courseICollection" data-id="286"> <b class="nofollow small-nocollect"></b> </div> </div> </div> </li> <li> <a target="_blank" href="https://www.php.cn/course/504.html" title="Little Turtle's zero-based introduction to learning Python video tutorial" class="wzrthreelaimg"> <img src="https://img.php.cn/upload/course/000/000/068/62590a67ce3a6655.png" alt="Little Turtle's zero-based introduction to learning Python video tutorial"/> </a> <div class="wzrthree-right"> <a target="_blank" title="Little Turtle's zero-based introduction to learning Python video tutorial" href="https://www.php.cn/course/504.html">Little Turtle's zero-based introduction to learning Python video tutorial</a> <div class="wzrthreerb"> <div >507244 times of learning</div> <div class="courseICollection" data-id="504"> <b class="nofollow small-nocollect"></b> </div> </div> </div> </li> <li> <a target="_blank" href="https://www.php.cn/course/901.html" title="Quick introduction to web front-end development" class="wzrthreelaimg"> <img src="https://img.php.cn/upload/course/000/000/067/64be28a53a4f6310.png" alt="Quick introduction to web front-end development"/> </a> <div class="wzrthree-right"> <a target="_blank" title="Quick introduction to web front-end development" href="https://www.php.cn/course/901.html">Quick introduction to web front-end development</a> <div class="wzrthreerb"> <div >215814 times of learning</div> <div class="courseICollection" data-id="901"> <b class="nofollow small-nocollect"></b> </div> </div> </div> </li> <li> <a target="_blank" href="https://www.php.cn/course/234.html" title="Master PS video tutorials from scratch" class="wzrthreelaimg"> <img src="https://img.php.cn/upload/course/000/000/068/62611f57ed0d4840.jpg" alt="Master PS video tutorials from scratch"/> </a> <div class="wzrthree-right"> <a target="_blank" title="Master PS video tutorials from scratch" href="https://www.php.cn/course/234.html">Master PS video tutorials from scratch</a> <div class="wzrthreerb"> <div >889940 times of learning</div> <div class="courseICollection" data-id="234"> <b class="nofollow small-nocollect"></b> </div> </div> </div> </li> </ul> <ul class="three" style="display: none;"> <li> <a target="_blank" href="https://www.php.cn/course/1648.html" title="[Web front-end] Node.js quick start" class="wzrthreelaimg"> <img src="https://img.php.cn/upload/course/000/000/067/662b5d34ba7c0227.png" alt="[Web front-end] Node.js quick start"/> </a> <div class="wzrthree-right"> <a target="_blank" title="[Web front-end] Node.js quick start" href="https://www.php.cn/course/1648.html">[Web front-end] Node.js quick start</a> <div class="wzrthreerb"> <div >7456 times of learning</div> <div class="courseICollection" data-id="1648"> <b class="nofollow small-nocollect"></b> </div> </div> </div> </li> <li> <a target="_blank" href="https://www.php.cn/course/1647.html" title="Complete collection of foreign web development full-stack courses" class="wzrthreelaimg"> <img src="https://img.php.cn/upload/course/000/000/067/6628cc96e310c937.png" alt="Complete collection of foreign web development full-stack courses"/> </a> <div class="wzrthree-right"> <a target="_blank" title="Complete collection of foreign web development full-stack courses" href="https://www.php.cn/course/1647.html">Complete collection of foreign web development full-stack courses</a> <div class="wzrthreerb"> <div >5943 times of learning</div> <div class="courseICollection" data-id="1647"> <b class="nofollow small-nocollect"></b> </div> </div> </div> </li> <li> <a target="_blank" href="https://www.php.cn/course/1646.html" title="Go language practical GraphQL" class="wzrthreelaimg"> <img src="https://img.php.cn/upload/course/000/000/067/662221173504a436.png" alt="Go language practical GraphQL"/> </a> <div class="wzrthree-right"> <a target="_blank" title="Go language practical GraphQL" href="https://www.php.cn/course/1646.html">Go language practical GraphQL</a> <div class="wzrthreerb"> <div >4929 times of learning</div> <div class="courseICollection" data-id="1646"> <b class="nofollow small-nocollect"></b> </div> </div> </div> </li> <li> <a target="_blank" href="https://www.php.cn/course/1645.html" title="550W fan master learns JavaScript from scratch step by step" class="wzrthreelaimg"> <img src="https://img.php.cn/upload/course/000/000/067/662077e163124646.png" alt="550W fan master learns JavaScript from scratch step by step"/> </a> <div class="wzrthree-right"> <a target="_blank" title="550W fan master learns JavaScript from scratch step by step" href="https://www.php.cn/course/1645.html">550W fan master learns JavaScript from scratch step by step</a> <div class="wzrthreerb"> <div >696 times of learning</div> <div class="courseICollection" data-id="1645"> <b class="nofollow small-nocollect"></b> </div> </div> </div> </li> <li> <a target="_blank" href="https://www.php.cn/course/1644.html" title="Python master Mosh, a beginner with zero basic knowledge can get started in 6 hours" class="wzrthreelaimg"> <img src="https://img.php.cn/upload/course/000/000/067/6616418ca80b8916.png" alt="Python master Mosh, a beginner with zero basic knowledge can get started in 6 hours"/> </a> <div class="wzrthree-right"> <a target="_blank" title="Python master Mosh, a beginner with zero basic knowledge can get started in 6 hours" href="https://www.php.cn/course/1644.html">Python master Mosh, a beginner with zero basic knowledge can get started in 6 hours</a> <div class="wzrthreerb"> <div >24685 times of learning</div> <div class="courseICollection" data-id="1644"> <b class="nofollow small-nocollect"></b> </div> </div> </div> </li> </ul> </div> <script> var mySwiper = new Swiper('.swiper2', { autoplay: false,//可选选项,自动滑动 slidesPerView : 'auto', }) $('.wzrthreeTab>div').click(function(e){ $('.wzrthreeTab>div').removeClass('check') $(this).addClass('check') $('.wzrthreelist>ul').css('display','none') $('.'+e.currentTarget.dataset.id).show() }) </script> </div> <div class="wzrFour"> <div class="wzrfour-title"> <div>Latest Downloads</div> <a href="https://www.php.cn/xiazai">More> </a> </div> <script> $(document).ready(function(){ var sjyx_banSwiper = new Swiper(".sjyx_banSwiperwz",{ speed:1000, autoplay:{ delay:3500, disableOnInteraction: false, }, pagination:{ el:'.sjyx_banSwiperwz .swiper-pagination', clickable :false, }, loop:true }) }) </script> <div class="wzrfourList swiper3"> <div class="wzrfourlTab swiper-wrapper"> <div class="check swiper-slide" data-id="onef">Web Effects <div></div></div> <div class="swiper-slide" data-id="twof">Website Source Code<div></div></div> <div class="swiper-slide" data-id="threef">Website Materials<div></div></div> <div class="swiper-slide" data-id="fourf">Front End Template<div></div></div> </div> <ul class="onef"> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a target="_blank" title="jQuery enterprise message form contact code" href="https://www.php.cn/toolset/js-special-effects/8071">[form button] jQuery enterprise message form contact code</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a target="_blank" title="HTML5 MP3 music box playback effects" href="https://www.php.cn/toolset/js-special-effects/8070">[Player special effects] HTML5 MP3 music box playback effects</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a target="_blank" title="HTML5 cool particle animation navigation menu special effects" href="https://www.php.cn/toolset/js-special-effects/8069">[Menu navigation] HTML5 cool particle animation navigation menu special effects</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a target="_blank" title="jQuery visual form drag and drop editing code" href="https://www.php.cn/toolset/js-special-effects/8068">[form button] jQuery visual form drag and drop editing code</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a target="_blank" title="VUE.JS imitation Kugou music player code" href="https://www.php.cn/toolset/js-special-effects/8067">[Player special effects] VUE.JS imitation Kugou music player code</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a target="_blank" title="Classic html5 pushing box game" href="https://www.php.cn/toolset/js-special-effects/8066">[html5 special effects] Classic html5 pushing box game</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a target="_blank" title="jQuery scrolling to add or reduce image effects" href="https://www.php.cn/toolset/js-special-effects/8065">[Picture special effects] jQuery scrolling to add or reduce image effects</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a target="_blank" title="CSS3 personal album cover hover zoom effect" href="https://www.php.cn/toolset/js-special-effects/8064">[Photo album effects] CSS3 personal album cover hover zoom effect</a> </div> </li> </ul> <ul class="twof" style="display:none"> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-source-code/8328" title="Home Decor Cleaning and Repair Service Company Website Template" target="_blank">[Front-end template] Home Decor Cleaning and Repair Service Company Website Template</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-source-code/8327" title="Fresh color personal resume guide page template" target="_blank">[Front-end template] Fresh color personal resume guide page template</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-source-code/8326" title="Designer Creative Job Resume Web Template" target="_blank">[Front-end template] Designer Creative Job Resume Web Template</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-source-code/8325" title="Modern engineering construction company website template" target="_blank">[Front-end template] Modern engineering construction company website template</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-source-code/8324" title="Responsive HTML5 template for educational service institutions" target="_blank">[Front-end template] Responsive HTML5 template for educational service institutions</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-source-code/8323" title="Online e-book store mall website template" target="_blank">[Front-end template] Online e-book store mall website template</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-source-code/8322" title="IT technology solves Internet company website template" target="_blank">[Front-end template] IT technology solves Internet company website template</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-source-code/8321" title="Purple style foreign exchange trading service website template" target="_blank">[Front-end template] Purple style foreign exchange trading service website template</a> </div> </li> </ul> <ul class="threef" style="display:none"> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-materials/3078" target="_blank" title="Cute summer elements vector material (EPS PNG)">[PNG material] Cute summer elements vector material (EPS PNG)</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-materials/3077" target="_blank" title="Four red 2023 graduation badges vector material (AI EPS PNG)">[PNG material] Four red 2023 graduation badges vector material (AI EPS PNG)</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-materials/3076" target="_blank" title="Singing bird and cart filled with flowers design spring banner vector material (AI EPS)">[banner picture] Singing bird and cart filled with flowers design spring banner vector material (AI EPS)</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-materials/3075" target="_blank" title="Golden graduation cap vector material (EPS PNG)">[PNG material] Golden graduation cap vector material (EPS PNG)</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-materials/3074" target="_blank" title="Black and white style mountain icon vector material (EPS PNG)">[PNG material] Black and white style mountain icon vector material (EPS PNG)</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-materials/3073" target="_blank" title="Superhero silhouette vector material (EPS PNG) with different color cloaks and different poses">[PNG material] Superhero silhouette vector material (EPS PNG) with different color cloaks and different poses</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-materials/3072" target="_blank" title="Flat style Arbor Day banner vector material (AI+EPS)">[banner picture] Flat style Arbor Day banner vector material (AI+EPS)</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-materials/3071" target="_blank" title="Nine comic-style exploding chat bubbles vector material (EPS+PNG)">[PNG material] Nine comic-style exploding chat bubbles vector material (EPS+PNG)</a> </div> </li> </ul> <ul class="fourf" style="display:none"> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-source-code/8328" target="_blank" title="Home Decor Cleaning and Repair Service Company Website Template">[Front-end template] Home Decor Cleaning and Repair Service Company Website Template</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-source-code/8327" target="_blank" title="Fresh color personal resume guide page template">[Front-end template] Fresh color personal resume guide page template</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-source-code/8326" target="_blank" title="Designer Creative Job Resume Web Template">[Front-end template] Designer Creative Job Resume Web Template</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-source-code/8325" target="_blank" title="Modern engineering construction company website template">[Front-end template] Modern engineering construction company website template</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-source-code/8324" target="_blank" title="Responsive HTML5 template for educational service institutions">[Front-end template] Responsive HTML5 template for educational service institutions</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-source-code/8323" target="_blank" title="Online e-book store mall website template">[Front-end template] Online e-book store mall website template</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-source-code/8322" target="_blank" title="IT technology solves Internet company website template">[Front-end template] IT technology solves Internet company website template</a> </div> </li> <li> <div class="wzrfourli"> <span class="layui-badge-dots wzrflr"></span> <a href="https://www.php.cn/toolset/website-source-code/8321" target="_blank" title="Purple style foreign exchange trading service website template">[Front-end template] Purple style foreign exchange trading service website template</a> </div> </li> </ul> </div> <script> var mySwiper = new Swiper('.swiper3', { autoplay: false,//可选选项,自动滑动 slidesPerView : 'auto', }) $('.wzrfourlTab>div').click(function(e){ $('.wzrfourlTab>div').removeClass('check') $(this).addClass('check') $('.wzrfourList>ul').css('display','none') $('.'+e.currentTarget.dataset.id).show() }) </script> </div> </div> </div> <footer> <div class="footer"> <div class="footertop"> <img src="/static/imghw/logo.png" alt=""> <p>Public welfare online PHP training,Help PHP learners grow quickly!</p> </div> <div class="footermid"> <a href="https://www.php.cn/about/us.html">About us</a> <a href="https://www.php.cn/about/disclaimer.html">Disclaimer</a> <a href="https://www.php.cn/update/article_0_1.html">Sitemap</a> </div> <div class="footerbottom"> <p> © php.cn All rights reserved </p> </div> </div> </footer> <input type="hidden" id="verifycode" value="/captcha.html"> <script>layui.use(['element', 'carousel'], function () {var element = layui.element;$ = layui.jquery;var carousel = layui.carousel;carousel.render({elem: '#test1', width: '100%', height: '330px', arrow: 'always'});$.getScript('/static/js/jquery.lazyload.min.js', function () {$("img").lazyload({placeholder: "/static/images/load.jpg", effect: "fadeIn", threshold: 200, skip_invisible: false});});});</script> <script src="/static/js/common_new.js"></script> <script type="text/javascript" src="/static/js/jquery.cookie.js?1734399954"></script> <script src="https://vdse.bdstatic.com//search-video.v1.min.js"></script> <link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css?2' type='text/css' media='all'/> <script type='text/javascript' src='/static/js/viewer.min.js?1'></script> <script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script> <script type="text/javascript" src="/static/js/global.min.js?5.5.53"></script> </body> </html>