How do I transpose this curl code to send it in a PHP file?
curl -X PUT -H "Content-Type: application/json" -H "Accept: application/json" -d
{
"status":"paused"
}
https://api.mercadolibre.com/items/ITEM_ID?access_token=YOUR_ACCESS_TOKEN
How do I transpose this curl code to send it in a PHP file?
curl -X PUT -H "Content-Type: application/json" -H "Accept: application/json" -d
{
"status":"paused"
}
https://api.mercadolibre.com/items/ITEM_ID?access_token=YOUR_ACCESS_TOKEN
$url = 'https://api.mercadolibre.com/items/ITEM_ID?access_token=YOUR_ACCESS_TOKEN';
$cabecalho = array('Content-Type: application/json', 'Accept: application/json');
$campos = json_encode(array('status' => 'paused'));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $cabecalho);
curl_setopt($ch, CURLOPT_POSTFIELDS, $campos);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
$resposta = curl_exec($ch);
curl_close($ch);
Perfect solution works perfectly just forgot the semicolon
$url = 'https://api.mercadolibre.com/items/ITEM_ID?access_token=YOUR_ACCESS_TOKEN';
$cabecalho = array('Content-Type: application/json', 'Accept: application/json') <<<<-------- adicionar o ";"
$campos = json_encode(array('status' => 'paused'));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $cabecalho);
curl_setopt($ch, CURLOPT_POSTFIELDS, $campos);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
$resposta = curl_exec($ch);
curl_close($ch);