QQInfo.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Components;
  3. class QQInfo {
  4. /**
  5. * 通过QQ号查询头像与昵称信息
  6. *
  7. * @param string $qq QQ号
  8. *
  9. * @return string
  10. */
  11. public static function getName($qq) {
  12. //向接口发起请求获取json数据
  13. $url = 'https://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?get_nick=1&uins='.$qq;
  14. $ret = mb_convert_encoding(Curl::send($url), "UTF-8", "GBK");
  15. // 接口是否异常
  16. //echo $ret;
  17. if(strpos($ret, $qq) !== false){
  18. //对获取的json数据进行截取并解析成数组
  19. $ret = json_decode(substr($ret, 17, -1), true);
  20. return stripslashes($ret[$qq][6]);
  21. }
  22. echo $qq.PHP_EOL;
  23. return false;
  24. }
  25. public static function getName2($qq) {
  26. //向接口发起请求获取json数据
  27. $url = 'https://api.toubiec.cn/qq?qq='.$qq.'&size=100';
  28. $ret = json_decode(Curl::send($url), true);
  29. // 接口是否异常
  30. if($ret && $ret['code'] == 200){
  31. return $ret['name'];
  32. }
  33. echo $qq.PHP_EOL;
  34. return false;
  35. }
  36. public static function getName3($qq) {
  37. //向接口发起请求获取json数据
  38. $url = 'https://api.unipay.qq.com/v1/r/1450000186/wechat_query?cmd=1&pf=mds_storeopen_qb-__mds_qqclub_tab_-html5&pfkey=pfkey&from_h5=1&from_https=1&openid=openid&openkey=openkey&session_id=hy_gameid&session_type=st_dummy&qq_appid=&offerId=1450000186&sandbox=&provide_uin='.$qq;
  39. $ret = json_decode(Curl::send($url), true);
  40. // 接口是否异常
  41. if($ret && $ret['ret'] == 0){
  42. return urldecode($ret['nick']);
  43. }
  44. echo $qq.PHP_EOL;
  45. return false;
  46. }
  47. }