PHP curl is not working in Shopify API properly. Sometimes it works and I get a response from Shopify but maximum times I get no response or 504 Gateway Timeout. But it works perfectly in the postman.
CURL Code:
$url = "https://refiral5-2.myshopify.com/admin/script_tags.json";
$shops_token = '64cbba144bc3cb166da91be13103f785';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPGET, true);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_MAXREDIRS, 3);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-Shopify-Access-Token: $shops_token"));
$response = curl_exec($curl);
curl_close($curl);
答案 0 :(得分:0)
当我尝试发布包含太多图片的产品时,我收到了504 Gateway Timeout错误。我的理论是Shopify在处理API请求时有时间限制,因此如果您的请求需要很长时间才能处理,那么它将返回此错误。