Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- class EnviarDiscordController extends Controller
- {
- public function enviar() {
- $registro = "Torta de Chocolate";
- $url_webhook = "TU-WEBHOOK-URL-DISCORD";
- $fechayhora = date("c", strtotime("now"));
- $datos_json = json_encode(
- [
- "content" => "Esto es un Contenido",
- "username" => "Nube Colectiva",
- "avatar_url" => "https://nubecolectiva.com/img/logo.png",
- "embeds" => [
- [
- "title" => $registro,
- "type" => "rich",
- "description" => "Esta es una descripción",
- "url" => "https://nubecolectiva.com/",
- "timestamp" => $fechayhora,
- "thumbnail" => [
- "url" => "https://blog.nubecolectiva.com/wp-content/uploads/2022/03/edit_jimg_destacada_blog_devs-530x353.png"
- ],
- "image" => [
- "url" => "https://blog.nubecolectiva.com/wp-content/uploads/2022/03/edit_jimg_destacada_blog_devs-530x353.png"
- ],
- "author" => [
- "name" => "Nube Colectiva",
- "url" => "https://nubecolectiva.com/"
- ]
- ]
- ]
- ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
- $curl = curl_init($url_webhook);
- curl_setopt( $curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
- curl_setopt( $curl, CURLOPT_POST, 1);
- curl_setopt( $curl, CURLOPT_POSTFIELDS, $datos_json);
- curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt( $curl, CURLOPT_HEADER, 0);
- curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1);
- $respuesta = curl_exec($curl);
- curl_close($curl);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement