请选择 进入手机版 | 继续访问电脑版

深蓝论坛

搜索
查看: 54|回复: 0

60秒读懂世界API接口源码

[复制链接]

522

主题

4

回帖

2026

积分

管理员

蛮荒网络

Rank: 9Rank: 9Rank: 9

积分
2026

勋章4勋章6冰墩墩滑稽单身狗

发表于 2023-9-2 13:18:41 | 显示全部楼层 |阅读模式
  1. <?php
  2. /**
  3. * Plugin Name: 60秒读懂世界
  4. * Author: 大米api
  5. * Author URL: https://api.qqsuu.cn/
  6. */

  7. function callAPI($url, $params) {
  8.   $queryString = http_build_query(array_filter($params));
  9.   $requestURL = $url . '?' . $queryString;

  10.   $options = array(
  11.     'http' => array(
  12.       'method' => 'GET',
  13.       'header' => 'Content-type: application/x-www-form-urlencoded',
  14.       'ignore_errors' => true
  15.     )
  16.   );

  17.   $context = stream_context_create($options);
  18.   $response = file_get_contents($requestURL, false, $context);

  19.   if ($response === false) {
  20.     // 请求失败
  21.     echo "请求失败";
  22.   } else {
  23.     // 请求成功,输出响应内容
  24.         if($params['type']=='json'){
  25.                 echo $response;
  26.         }else{
  27.                 header("Content-Type:image/png");
  28.                 echo $response;
  29.         }
  30.    
  31.   }
  32. }

  33. $url = 'https://api.qqsuu.cn/api/dm-60s?apiKey=bVd6b080ejhaMEpabG0yMmJCaWNYZz09';

  34. $type = isset($_GET['type']) ? $_GET['type'] : '';

  35. $params = array(
  36.   'type' => $type
  37. );

  38. callAPI($url, $params);

复制代码
保存为.PHP访问即可使用,输出 ?type=json
大牛马一个
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表