QQ.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace Sakura\API;
  3. class QQ
  4. {
  5. public static function get_qq_info($qq) {
  6. $get_info = file_get_contents('http://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?get_nick=1&uins=' . $qq);
  7. $get_info = mb_convert_encoding($get_info, "UTF-8", "GBK");
  8. $name = json_decode(substr($get_info, 17, -1), true);
  9. if ($name) {
  10. $output = array(
  11. 'status' => 200,
  12. 'success' => true,
  13. 'message' => 'success',
  14. 'avatar' => 'https://q.qlogo.cn/headimg_dl?dst_uin=' . $qq . '&spec=100',
  15. 'name' => $name[$qq][6],
  16. );
  17. } else {
  18. $output = array(
  19. 'status' => 404,
  20. 'success' => false,
  21. 'message' => 'QQ number not exist.'
  22. );
  23. }
  24. return $output;
  25. }
  26. public static function get_qq_avatar($encrypted) {
  27. global $sakura_privkey;
  28. if (isset($encrypted)) {
  29. $iv = str_repeat($sakura_privkey, 2);
  30. $encrypted = base64_decode(urldecode($encrypted));
  31. $qq_number = openssl_decrypt($encrypted, 'aes-128-cbc', $sakura_privkey, 0, $iv);
  32. preg_match('/^\d{3,}$/', $qq_number, $matches);
  33. return 'https://q2.qlogo.cn/headimg_dl?dst_uin=' . $matches[0] . '&spec=100';
  34. }
  35. }
  36. }