Chatgtp API接口白嫖方法

Chatgtp API接口白嫖方法

枫
2023-08-20 / 2 评论 / 124 阅读 / 耗时 158ms / 正在检测是否收录...

介绍

  有一些gtp网页是可以抓到它的数据接口的,打开网页,按F12进行抓包,获取他的接口,实现白嫖的方法,也可以利用这个接口自己搭建个API接口,白嫖 表情

抓包

站点:https://ai.haircv.com/
很显然这是他的数据包,post请求,也可以看到他响应的内容

代码

下面是获取接口,然后再调用成一个API,自己新建一个php文件,就可调用了


<?php

$msg = $_GET['msg'];//需要提问的内容

// 构建 POST 请求的数据
$data = array(
    'messages' => array(
        array(
            'role' => 'system',
            'content' => 'IMPORTANT: You are a virtual assistant powered by the gpt-3.5-turbo model, now time is '
        ),
        array(
            'role' => 'user',
            'content' => $msg
        )
    ),
    'stream' => true,
    'model' => 'gpt-3.5-turbo',
    'temperature' => 0.5,
    'presence_penalty' => 0
);

// 发送 POST 请求
$curl = curl_init();
$url = 'https://ai.haircv.com/api/openai/v1/chat/completions'; //这里填你抓到的接口
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$response = curl_exec($curl);
curl_close($curl);
//数据处理
$pattern = '/content\":\"(.*?)\"}/';
preg_match_all($pattern, $response, $matches);
foreach ($matches[1] as $result) {
    echo $result;
}

2

海报

正在生成.....

评论 (2)

取消
  1. 头像
    匿名
    安阳 ·Windows 10 · Google Chrome
    河南省洛阳市 联通 河南省 沙发

    学习到了,感谢博主

    Windows 10   Microsoft Edge  回复 删除 垃圾
  2. 头像
    Echo
    XX ·Windows X64 · QQ Browser
    广东省东莞市 移动 广东省 板凳

    终于找到这篇文章了,感谢作者的分享!

    Android 13   手机QQ  回复 删除 垃圾