App reviews, troubleshooting, and recommendations
hi! i have this code
private function makePostRequest($url, $postData) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($postData)); // Codifica a JSON aquí
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Accept: application/json', // Asegúrate de aceptar JSON
'Authorization: Basic ' . base64_encode("{$this->apiKey}:{$this->password}")
]);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$error = curl_error($curl);
curl_close($curl);
return [
'response' => json_decode($response, true),
'http_code' => $httpCode,
'error' => $error
];
}
and i trying to fulfill a order , for that i have this function
public function fulfillOrder($orderId, $location_id, $fullfilment_order_id, $trackingNumber, $trackingUrl) {
$apiUrl = "{$this->start_url}/orders/{$orderId}/fulfillments.json";
$postData = [
'fulfillment' => [
'line_items_by_fulfillment_order' => [
[
'fulfillment_order_id' => $fullfilment_order_id
]
],
'notify_customer' => true,
'tracking_info' => [
'number' => $trackingNumber,
'company' => 'Other',
'url' => $trackingUrl,
],
'location_id' => $location_id
]
];
echo $apiUrl;
$response = $this->makePostRequest($apiUrl, $postData);
echo "<pre>";
print_r($postData);
print_r($response);
echo "</pre>";
if ($response['http_code'] == 201) {
return $response['response'];
} else {
return [
'error' => $response['error'],
'http_code' => $response['http_code'],
'response' => $response['response']
];
}
}
but i got this error:
Array
(
[response] =>
[http_code] => 406
[error] =>
)
anyone can helpme pls
Hi @kahmra ,
You can try changing this line
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Accept: application/json', // Asegúrate de aceptar JSON
'Authorization: Basic ' . base64_encode("{$this->apiKey}:{$this->password}")
]);
to this
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'X-Shopify-Access-Token: ' . "{$this->password}"
]);
Let me know if it works.
The year-end shopping spree is around the corner! Is your online store ready for the ...
By JasonH Nov 10, 2024We recently spoke with Zopi developers @Zopi about how dropshipping businesses can enha...
By JasonH Oct 23, 2024A big shout out to all of the merchants who participated in our AMA with 2H Media: Holi...
By Jacqui Oct 21, 2024