Php 我想要帮助制造不和谐卷曲
我想通过token而不是bot和curl来发送消息并获取它,从而引起帖子的不和谐 就像python中的这个Php 我想要帮助制造不和谐卷曲,php,curl,discord,Php,Curl,Discord,我想通过token而不是bot和curl来发送消息并获取它,从而引起帖子的不和谐 就像python中的这个 $ch=curl_init(); curl_setopt($ch,CURLOPT_URL,”https://discord.com/api/v8/channels/YOURID/messages"); curl_setopt($ch,CURLOPT_HTTPHEADER,['authorization'=>'YOURTOKEN']); curl_setopt($ch,CURLOPT_P
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,”https://discord.com/api/v8/channels/YOURID/messages");
curl_setopt($ch,CURLOPT_HTTPHEADER,['authorization'=>'YOURTOKEN']);
curl_setopt($ch,CURLOPT_POSTFIELDS,json_encode(['content'=>'hello world']);
curl_exec($ch);
上面的代码返回未经授权的使用。它的语法更接近pythons请求,然后直接使用curl
<?php
use GuzzleHttp\Client;
$client = new Client();
$response = $client->post( 'https://discord.com/api/v8/channels/YOURID/messages', [
'headers' => [ 'authorization' => 'YOURTOKEN'],
'body' => json_encode(['content' => 'hello world'])
]);
那么,你的想法是什么?你可以在下面看到
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://discord.com/api/v8/channels/YOURID/messages");
curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'authorization' => 'YOURTOKEN']);
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode(['content' => 'hello world']));
curl_exec($ch);