Skip to content

Instantly share code, notes, and snippets.

@jmarreros
Last active November 18, 2016 13:14
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 jmarreros/1057f7f451a701b4a3a90f052e39c363 to your computer and use it in GitHub Desktop.
Save jmarreros/1057f7f451a701b4a3a90f052e39c363 to your computer and use it in GitHub Desktop.
En donde 123 es el ID del posts a modificar
<?php
$host = 'http://tudominio.com/wp-json/wp/v2/posts/123';
$data = array('title' => 'Titulo Post Nuevo Modif', 'content' => 'Contenido de prueba Modif', 'status' => 'publish');
$data_string = json_encode($data);
$headers = array(
'Content-Type:application/json',
'Content-Length: ' . strlen($data_string),
'Authorization: Basic '. base64_encode('admin:clave')
);
$ch = curl_init($host);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($ch);
curl_close($ch);
echo($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment