QQ.php 1.3 KB

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