LovelyCat.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. <?php
  2. class lovelyCat
  3. {
  4. private static $instance;
  5. /**
  6. * @var int 事件类型<br><br> 100=> 私聊消息<br>200=> 群聊消息<br>300=> 暂无<br>400=> 群成员增加<br>410=> 群成员减少<br>500=> 收到好友请求<br>600=> 二维码收款<br>700=> 收到转账<br>800=> 软件开始启动<br>900=> 新的账号登录完成<br>910=> 账号下线
  7. */
  8. public $type;
  9. /**
  10. * @var string 1级来源id(群消息事件下,1级来源为群id,2级来源为发消息的成员id,私聊事件下都一样)
  11. */
  12. public $from_wxid;
  13. /**
  14. * @var string 1级来源昵称(比如发消息的人昵称)<br>
  15. */
  16. public $from_name;
  17. /**
  18. * @var string 2级来源id(群消息事件下,1级来源为群id,2级来源为发消息的成员id,私聊事件下都一样)
  19. */
  20. public $final_from_wxid;
  21. /**
  22. * @var string 2级来源昵称
  23. */
  24. public $final_from_name;
  25. /**
  26. * @var string 当前登录的账号(机器人)标识id
  27. */
  28. public $robot_wxid;
  29. /**
  30. * @var string 消息内容
  31. */
  32. public $msg;
  33. /**
  34. * @var int 请求时间(时间戳10位版本)
  35. */
  36. public $time;
  37. /**
  38. * @var string 机器猫接口地址
  39. */
  40. public $url = "http://106.12.172.186:8073/send";
  41. public function __construct($config = null)
  42. {
  43. if (!empty($config)) {//未配置,使用默认配置
  44. $this->url = $config['url'];
  45. }
  46. $this->parseWechat($_POST);
  47. }
  48. /**
  49. * 单例模式使用
  50. * @param string|null $url 可爱猫API接口地址
  51. * @return lovelyCat
  52. */
  53. public static function getInstance($url = null)
  54. {
  55. if (!isset(self::$instance)) {
  56. $instance = new self(['url' => $url]);
  57. self::$instance = $instance;
  58. }
  59. return self::$instance;
  60. }
  61. /**
  62. * 解析可爱猫回调消息
  63. * @param $data
  64. */
  65. public function parseWechat($data)
  66. {
  67. $this->type = $data['type'];
  68. $this->from_wxid = $data['from_wxid'];
  69. $this->from_name = urldecode($data['from_name']);
  70. $this->final_from_wxid = $data['final_from_wxid'];
  71. $this->final_from_name = urldecode($data['final_from_name']);
  72. $this->robot_wxid = $data['robot_wxid'];
  73. $this->msg = urldecode($data['msg']);
  74. $this->time = $data['time'];
  75. }
  76. /**
  77. * 发送文字消息(好友或者群)
  78. *
  79. * @access public
  80. * @param string $msg 消息内容
  81. * @param string $robwxid 登录账号id,用哪个账号去发送这条消息,不传则使用当前回调的机器人ID
  82. * @param string $to_wxid 对方的id,可以是群或者好友id,不传则表示回复当前消息
  83. * @return array
  84. */
  85. public function sendTextMsg($msg, $robwxid = null, $to_wxid = null)
  86. {
  87. $data = array();
  88. $data['type'] = 100;
  89. $data['msg'] = urlencode($msg); // 发送内容
  90. $data['to_wxid'] = $to_wxid ?: $this->from_wxid; // 对方id
  91. $data['robot_wxid'] = $robwxid ?: $this->robot_wxid; // 账户id,用哪个账号去发送这条消息
  92. $response = array('data' => json_encode($data));
  93. return $this->sendRequest($response, 'post');
  94. }
  95. /**
  96. * 发送群消息并艾特某人
  97. *
  98. * @access public
  99. * @param string $robwxid 账户id,用哪个账号去发送这条消息
  100. * @param string $group_wxid 群id
  101. * @param string $at_wxid 艾特的id,群成员的id
  102. * @param string $at_name 艾特的昵称,群成员的昵称
  103. * @param string $msg 消息内容
  104. * @return array
  105. */
  106. public function sendGroupAtMsg($robwxid, $group_wxid, $at_wxid, $at_name, $msg)
  107. {
  108. $data = array();
  109. $data['type'] = 102;
  110. $data['msg'] = urlencode($msg);
  111. $data['to_wxid'] = $group_wxid;
  112. $data['at_wxid'] = $at_wxid;
  113. $data['at_name'] = $at_name;
  114. $data['robot_wxid'] = $robwxid;
  115. $response = array('data' => json_encode($data));
  116. return $this->sendRequest($response, 'post');
  117. }
  118. /**
  119. * 发送图片消息
  120. *
  121. * @access public
  122. * @param string $img_url 图片的绝对路径,可以是本地图片地址/网络图片地址
  123. * @param string $robwxid 登录账号id,用哪个账号去发送这条消息,不传则使用当前机器人ID
  124. * @param string $to_wxid 对方的id,可以是群或者好友id,不传则表示回复当前消息
  125. * @return array
  126. */
  127. public function sendImageMsg($img_url, $robwxid = null, $to_wxid = null)
  128. {
  129. $data = array();
  130. $data['type'] = 103;
  131. $data['msg'] = $img_url;
  132. $data['to_wxid'] = $to_wxid ?: $this->from_wxid;
  133. $data['robot_wxid'] = $robwxid ?: $this->robot_wxid;
  134. $response = array('data' => json_encode($data));
  135. return $this->sendRequest($response, 'post');
  136. }
  137. /**
  138. * 发送视频消息
  139. *
  140. * @access public
  141. * @param string $mp4_path 视频文件的绝对路径
  142. * @param string $robwxid 账户id,用哪个账号去发送这条消息
  143. * @param string $to_wxid 对方的id,可以是群或者好友id
  144. * @return array
  145. */
  146. public function sendVideoMsg($mp4_path, $robwxid = null, $to_wxid = null)
  147. {
  148. $data = array();
  149. $data['type'] = 104;
  150. $data['msg'] = $mp4_path;
  151. $data['to_wxid'] = $to_wxid ?: $this->from_wxid;
  152. $data['robot_wxid'] = $robwxid ?: $this->robot_wxid;
  153. $response = array('data' => json_encode($data));
  154. return $this->sendRequest($response, 'post');
  155. }
  156. /**
  157. * 发送文件消息
  158. *
  159. * @access public
  160. * @param string $file_path 文件的绝对路径
  161. * @param string $robwxid 账户id,用哪个账号去发送这条消息
  162. * @param string $to_wxid 对方的id,可以是群或者好友id
  163. * @return array
  164. */
  165. public function sendFileMsg($file_path, $robwxid = null, $to_wxid = null)
  166. {
  167. $data = array();
  168. $data['type'] = 105;
  169. $data['msg'] = $file_path; // 发送的文件的绝对路径
  170. $data['to_wxid'] = $to_wxid ?: $this->from_wxid; // 对方id(默认发送至来源的id,也可以发给其他人)
  171. $data['robot_wxid'] = $robwxid ?: $this->robot_wxid; // 账户id,用哪个账号去发送这条消息
  172. $response = array('data' => json_encode($data));
  173. return $this->sendRequest($response, 'post');
  174. }
  175. /**
  176. * 发送动态表情
  177. *
  178. * @access public
  179. * @param string $path 动态表情文件(通常是gif)的绝对路径
  180. * @param string $robwxid 账户id,用哪个账号去发送这条消息
  181. * @param string $to_wxid 对方的id,可以是群或者好友id
  182. * @return array
  183. */
  184. public function sendEmojiMsg($path, $robwxid = null, $to_wxid = null)
  185. {
  186. $data = array();
  187. $data['type'] = 106;
  188. $data['msg'] = $path; // 发送的动态表情的绝对路径
  189. $data['to_wxid'] = $to_wxid ?: $this->from_wxid; // 对方id(默认发送至来源的id,也可以发给其他人)
  190. $data['robot_wxid'] = $robwxid ?: $this->robot_wxid; // 账户id,用哪个账号去发送这条消息
  191. $response = array('data' => json_encode($data));
  192. return $this->sendRequest($response, 'post');
  193. }
  194. /**
  195. * 发送分享链接
  196. *
  197. * @access public
  198. * @param string $title 链接标题
  199. * @param string $text 链接内容
  200. * @param string $target_url 跳转链接
  201. * @param string $pic_url 图片链接
  202. * @param string $robwxid 账户id,用哪个账号去发送这条消息
  203. * @param string $to_wxid 对方的id,可以是群或者好友id
  204. * @return array
  205. */
  206. public function sendLinkMsg($title, $text, $target_url, $pic_url, $robwxid = null, $to_wxid = null)
  207. {
  208. // 封装链接结构体
  209. $link = array();
  210. $link['title'] = $title;
  211. $link['text'] = $text;
  212. $link['url'] = $target_url;
  213. $link['pic'] = $pic_url;
  214. $data = array();
  215. $data['type'] = 107;
  216. $data['msg'] = $link; // 发送的分享链接结构体
  217. $data['to_wxid'] = $to_wxid ?: $this->from_wxid;
  218. $data['robot_wxid'] = $robwxid ?: $this->robot_wxid;
  219. $response = array('data' => json_encode($data));
  220. return $this->sendRequest($response, 'post');
  221. }
  222. /**
  223. * 发送音乐分享
  224. *
  225. * @access public
  226. * @param string $name 歌曲名字
  227. * @param string $robwxid 账户id,用哪个账号去发送这条消息
  228. * @param string $to_wxid 对方的id,可以是群或者好友id
  229. * @return array
  230. */
  231. public function sendMusicMsg($name, $robwxid = null, $to_wxid = null)
  232. {
  233. $data = array();
  234. $data['type'] = 108;
  235. $data['msg'] = $name;
  236. $data['to_wxid'] = $to_wxid ?: $this->from_wxid;
  237. $data['robot_wxid'] = $robwxid ?: $this->robot_wxid;
  238. $response = array('data' => json_encode($data));
  239. return $this->sendRequest($response, 'post');
  240. }
  241. /**
  242. * 取指定登录账号的昵称
  243. *
  244. * @access public
  245. * @param string $robwxid 账户id
  246. * @return array 账号昵称
  247. */
  248. public function getRobotName($robwxid = null)
  249. {
  250. $data = array();
  251. $data['type'] = 201;
  252. $data['robot_wxid'] = $robwxid ?: $this->robot_wxid;
  253. $response = array('data' => json_encode($data));
  254. return $this->sendRequest($response, 'post');
  255. }
  256. /**
  257. * 取指定登录账号的头像
  258. *
  259. * @access public
  260. * @param string $robwxid 账户id
  261. * @return array 头像http地址
  262. */
  263. public function getRobotHeadImageUrl($robwxid = null)
  264. {
  265. $data = array();
  266. $data['type'] = 202;
  267. $data['robot_wxid'] = $robwxid ?: $this->robot_wxid; // 账户id
  268. $response = array('data' => json_encode($data));
  269. return $this->sendRequest($response, 'post');
  270. }
  271. /**
  272. * 取登录账号列表
  273. *
  274. * @access public
  275. * @return array 当前框架已登录的账号信息列表
  276. */
  277. public function getLoggedAccount_list()
  278. {
  279. $data = array();
  280. $data['type'] = 203;
  281. $response = array('data' => json_encode($data));
  282. return $this->sendRequest($response, 'post');
  283. }
  284. /**
  285. * 取好友列表
  286. *
  287. * @access public
  288. * @param string $robwxid 账户id
  289. * @param int $is_refresh 是否刷新
  290. * @return array 当前框架已登录的账号信息列表
  291. */
  292. public function getFriendList($robwxid = '', $is_refresh = 0)
  293. {
  294. $data = array();
  295. $data['type'] = 204;
  296. $data['robot_wxid'] = $robwxid; // 账户id(可选,如果填空字符串,即取所有登录账号的好友列表,反正取指定账号的列表)
  297. $data['is_refresh'] = $is_refresh; // 是否刷新列表,0 从缓存获取 / 1 刷新并获取
  298. $response = array('data' => json_encode($data));
  299. return $this->sendRequest($response, 'post');
  300. }
  301. /**
  302. * 取群聊列表
  303. *
  304. * @access public
  305. * @param string $robwxid 账户id
  306. * @param int $is_refresh 是否刷新
  307. * @return array 当前框架已登录的账号信息列表
  308. */
  309. public function getGroupList($robwxid = '', $is_refresh = 0)
  310. {
  311. $data = array();
  312. $data['type'] = 205;
  313. $data['robot_wxid'] = $robwxid; // 账户id(可选,如果填空字符串,即取所有登录账号的好友列表,反正取指定账号的列表)
  314. $data['is_refresh'] = $is_refresh; // 是否刷新列表,0 从缓存获取 / 1 刷新并获取
  315. $response = array('data' => json_encode($data));
  316. return $this->sendRequest($response, 'post');
  317. }
  318. /**
  319. * 取群成员列表
  320. *
  321. * @access public
  322. * @param string $robwxid 账户id
  323. * @param string $group_wxid 群id
  324. * @param int $is_refresh 是否刷新
  325. * @return array 当前框架已登录的账号信息列表
  326. */
  327. public function getGroupMemberList($robwxid, $group_wxid, $is_refresh = 0)
  328. {
  329. $data = array();
  330. $data['type'] = 206;
  331. $data['robot_wxid'] = $robwxid; // 账户id
  332. $data['group_wxid'] = $group_wxid; // 群id
  333. $data['is_refresh'] = $is_refresh; // 是否刷新列表,0 从缓存获取 / 1 刷新并获取
  334. $response = array('data' => json_encode($data));
  335. $result = $this->sendRequest($response, 'post');
  336. return json_decode($result, true);
  337. }
  338. /**
  339. * 取群成员资料
  340. *
  341. * @access public
  342. * @param string $robwxid 账户id
  343. * @param string $group_wxid 群id
  344. * @param string $member_wxid 群成员id
  345. * @return array
  346. */
  347. public function getGroupMember($robwxid, $group_wxid, $member_wxid)
  348. {
  349. $data = array();
  350. $data['type'] = 207;
  351. $data['robot_wxid'] = $robwxid; // 账户id,取哪个账号的资料
  352. $data['group_wxid'] = $group_wxid; // 群id
  353. $data['member_wxid'] = $member_wxid; // 群成员id
  354. $response = array('data' => json_encode($data));
  355. return $this->sendRequest($response, 'post');
  356. }
  357. /**
  358. * 接收好友转账
  359. *
  360. * @access public
  361. * @param string $robwxid 账户id
  362. * @param string $friend_wxid 朋友id
  363. * @param $json_string
  364. * @return array
  365. */
  366. public function acceptTransfer($robwxid = null, $friend_wxid = null, $json_string = null)
  367. {
  368. $data = array();
  369. $data['type'] = 301;
  370. $data['robot_wxid'] = $robwxid ?: $this->robot_wxid; // 账户id
  371. $data['friend_wxid'] = $friend_wxid ?: $this->from_wxid; // 朋友id
  372. $data['msg'] = $json_string ?: $this->msg; // 转账事件原消息
  373. $response = array('data' => json_encode($data));
  374. return $this->sendRequest($response, 'post');
  375. }
  376. /**
  377. * 同意群聊邀请
  378. *
  379. * @access public
  380. * @param string $robwxid 账户id
  381. * @param string $json_string 同步消息事件中群聊邀请原消息
  382. * @return array
  383. */
  384. public function agreeGroupInvite($robwxid = null, $json_string = null)
  385. {
  386. $data = array();
  387. $data['type'] = 302;
  388. $data['robot_wxid'] = $robwxid ?: $this->robot_wxid; // 账户id
  389. $data['msg'] = $json_string ?: $this->msg; // 同步消息事件中群聊邀请原消息
  390. $response = array('data' => json_encode($data));
  391. return $this->sendRequest($response, 'post');
  392. }
  393. /**
  394. * 同意好友请求
  395. *
  396. * @access public
  397. * @param string $robwxid 账户id
  398. * @param string $json_string 好友请求事件中原消息
  399. * @return array
  400. */
  401. public function agreeFriendVerify($robwxid = null, $json_string = null)
  402. {
  403. $data = array();
  404. $data['type'] = 303;
  405. $data['robot_wxid'] = $robwxid ?: $this->robot_wxid; // 账户id
  406. $data['msg'] = $json_string ?: $this->msg; // 好友请求事件中原消息
  407. $response = array('data' => json_encode($data));
  408. return $this->sendRequest($response, 'post');
  409. }
  410. /**
  411. * 修改好友备注
  412. *
  413. * @access public
  414. * @param string $robwxid 机器人账户id
  415. * @param string $friend_wxid 好友id
  416. * @param string $note 新备注(空字符串则是删除备注)
  417. * @return array
  418. */
  419. public function setFriendNote($robwxid, $friend_wxid, $note)
  420. {
  421. $data = array();
  422. $data['type'] = 304;
  423. $data['robot_wxid'] = $robwxid;
  424. $data['friend_wxid'] = $friend_wxid;
  425. $data['note'] = $note;
  426. $response = array('data' => json_encode($data));
  427. return $this->sendRequest($response, 'post');
  428. }
  429. /**
  430. * 删除好友
  431. *
  432. * @access public
  433. * @param string $robwxid 机器人账户id
  434. * @param string $friend_wxid 好友id
  435. * @return array
  436. */
  437. public function deleteFriend($robwxid, $friend_wxid)
  438. {
  439. $data = array();
  440. $data['type'] = 305;
  441. $data['robot_wxid'] = $robwxid;
  442. $data['friend_wxid'] = $friend_wxid;
  443. $response = array('data' => json_encode($data));
  444. return $this->sendRequest($response, 'post');
  445. }
  446. /**
  447. * 踢出群成员
  448. *
  449. * @access public
  450. * @param string $member_wxid 群成员id
  451. * @param string $group_wxid 群id
  452. * @param string $robwxid 账户id
  453. * @return array|string
  454. */
  455. public function removeGroupMember($member_wxid, $group_wxid = null, $robwxid = null)
  456. {
  457. $data = array();
  458. $data['type'] = 306;
  459. $data['robot_wxid'] = $robwxid ?: $this->robot_wxid;
  460. $data['group_wxid'] = $group_wxid ?: $this->from_wxid;
  461. $data['member_wxid'] = $member_wxid;
  462. $response = array('data' => json_encode($data));
  463. return $this->sendRequest($response, 'post');
  464. }
  465. /**
  466. * 修改群名称
  467. *
  468. * @access public
  469. * @param string $robwxid 账户id
  470. * @param string $group_wxid 群id
  471. * @param string $group_name 新群名
  472. * @return array
  473. */
  474. public function setGroupName($robwxid, $group_wxid, $group_name)
  475. {
  476. $data = array();
  477. $data['type'] = 307;
  478. $data['robot_wxid'] = $robwxid; // 账户id
  479. $data['group_wxid'] = $group_wxid; // 群id
  480. $data['group_name'] = $group_name; // 新群名
  481. $response = array('data' => json_encode($data));
  482. return $this->sendRequest($response, 'post');
  483. }
  484. /**
  485. * 修改群公告
  486. *
  487. * @access public
  488. * @param string $robwxid 账户id
  489. * @param string $group_wxid 群id
  490. * @param string $notice 新公告
  491. * @return array
  492. */
  493. public function setGroupNotice($robwxid, $group_wxid, $notice)
  494. {
  495. $data = array();
  496. $data['type'] = 308;
  497. $data['robot_wxid'] = $robwxid; // 账户id
  498. $data['group_wxid'] = $group_wxid; // 群id
  499. $data['notice'] = $notice; // 新公告
  500. $response = array('data' => json_encode($data));
  501. return $this->sendRequest($response, 'post');
  502. }
  503. /**
  504. * 建立新群
  505. *
  506. * @access public
  507. * @param string $robwxid 账户id
  508. * @param array $friends 三个人及以上的好友id数组,['wxid_1xxx', 'wxid_2xxx', 'wxid_3xxx', 'wxid_4xxx']
  509. * @return array
  510. */
  511. public function creatGroup($robwxid, array $friends)
  512. {
  513. $data = array();
  514. $data['type'] = 309;
  515. $data['robot_wxid'] = $robwxid; // 账户id
  516. $data['friends'] = $friends; // 好友id数组
  517. $response = array('data' => json_encode($data));
  518. return $this->sendRequest($response, 'post');
  519. }
  520. /**
  521. * 退出群聊
  522. *
  523. * @access public
  524. * @param string $robwxid 账户id
  525. * @param string $group_wxid 群id
  526. * @return array
  527. */
  528. public function quitGroup($robwxid, $group_wxid)
  529. {
  530. $data = array();
  531. $data['type'] = 310;
  532. $data['robot_wxid'] = $robwxid; // 账户id
  533. $data['group_wxid'] = $group_wxid; // 群id
  534. $response = array('data' => json_encode($data));
  535. return $this->sendRequest($response, 'post');
  536. }
  537. /**
  538. * 邀请加入群聊
  539. *
  540. * @access public
  541. * @param string $robwxid 账户id
  542. * @param string $group_wxid 群id
  543. * @param string $friend_wxid 好友id
  544. * @return array
  545. */
  546. public function inviteInGroup($robwxid, $group_wxid, $friend_wxid)
  547. {
  548. $data = array();
  549. $data['type'] = 311;
  550. $data['robot_wxid'] = $robwxid;
  551. $data['group_wxid'] = $group_wxid;
  552. $data['friend_wxid'] = $friend_wxid;
  553. $response = array('data' => json_encode($data));
  554. return $this->sendRequest($response, 'post');
  555. }
  556. /**
  557. * 执行一个 HTTP 请求,仅仅是post组件,其他语言请自行替换即可
  558. *
  559. * @param mixed $params 表单参数
  560. * @param int $timeout 超时时间
  561. * @param string $method 请求方法 post / get
  562. * @return array|string
  563. */
  564. public function sendRequest($params, $method = 'get', $timeout = 3)
  565. {
  566. $curl = curl_init();
  567. $is_https = stripos($this->url, 'https://') === 0 ? true : false;
  568. if ('get' == $method) {//以GET方式发送请求
  569. curl_setopt($curl, CURLOPT_URL, $this->url);
  570. } else {//以POST方式发送请求
  571. curl_setopt($curl, CURLOPT_URL, $this->url);
  572. curl_setopt($curl, CURLOPT_POST, 1);//post提交方式
  573. curl_setopt($curl, CURLOPT_POSTFIELDS, $params);//设置传送的参数
  574. }
  575. curl_setopt($curl, CURLOPT_HEADER, false);//设置header
  576. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);//要求结果为字符串且输出到屏幕上
  577. curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout);//设置等待时间
  578. if ($is_https) {
  579. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
  580. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1); // 从证书中检查SSL加密算法是否存在
  581. }
  582. $res = curl_exec($curl);//运行curl
  583. $err = curl_error($curl);
  584. if (false === $res || !empty($err)) {
  585. // $Errno = curl_errno($curl);
  586. // $Info = curl_getinfo($curl);
  587. // curl_close($curl);
  588. return false;//$err . ' result: ' . $res . 'error_msg: ' . $Errno;
  589. }
  590. curl_close($curl);//关闭curl
  591. $res = json_decode($res, true);
  592. $data = json_decode($res['data'], true);
  593. if ($data) {
  594. $res = $data;
  595. } else {
  596. $res = urldecode($res['data']);
  597. }
  598. return $res;
  599. }
  600. }