I have a question about how api rest work, I can not find how to send a request.
I'm trying the shopify api and I have the following code:
$baseUrl = 'https://xxxx:[email protected]/admin'; //Api URL removed for security reasons.
$ordercreate = array ('line_items','variant_id' => '1480829665339',
'quantity' => '1');
$ch = curl_init($baseUrl.'/orders.json'); //set the url
$data_string = json_encode(array('order' => $ordercreate)); //encode the product as json
echo $data_string;
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); //specify this as a POST
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); //set the POST string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //specify return value as string
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
); //specify that this is a JSON call
$server_output = curl_exec ($ch); //get server output if you wish to error handle / debug
echo $server_output;
curl_close ($ch); //close the connection
I would like to know how I can send this
{
"order": {
"email": "[email protected]",
"fulfillment_status": "fulfilled",
"line_items": [
{
"variant_id": 447654529,
"quantity": 1
}
]
}
}
In the php file