Advertisement
xladomaz

User dIscord http api request

Dec 2nd, 2018
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. function discordSend($method, $url, $token, $postfields='') {
  2.     $ch = curl_init('https://discordapp.com/api/'. $url);
  3.     curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  4.     curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
  5.     curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
  6.     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
  7.     curl_setopt($ch, CURLOPT_HTTPHEADER, [
  8.         'Authorization: ' .$token,
  9.         'Content-Type: application/json'
  10.     ]);
  11.     curl_setopt($ch,CURLOPT_POSTFIELDS,json_encode($postfields));
  12.     $response = json_decode(curl_exec($ch),true);
  13.     curl_close($ch);
  14.     return $response;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement