Skip to content

Instantly share code, notes, and snippets.

@porfidev
Created October 17, 2019 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save porfidev/c5e46782169957351c83da4f3c4a5755 to your computer and use it in GitHub Desktop.
Save porfidev/c5e46782169957351c83da4f3c4a5755 to your computer and use it in GitHub Desktop.
Peticiones HTTP post sin Curl
<?php
include('vendor/rmccue/requests/library/Requests.php');
Requests::register_autoloader();
$url = 'https://jsonplaceholder.typicode.com/posts';
$postData = array([
'title' => 'Hola Mundo',
'body' => 'Este es un ejemplo de envio con POST',
'userId' => 1,
]);
$headers = array([
'Content-type' => 'application/json; charset=UTF-8'
]);
$responsePost = Requests::post($url, null, $postData);
echo json_encode($responsePost);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment