Ich versuche, einen curl Anruf zu einem BigCommerce-Shop lokal zu machen, aber ich bekomme keine Antwort. Das Geschäft wird in einer anderen Domäne gehostet. Wenn die API url manuell ausgeführt wird, funktioniert es.Curl Anruf an BigCommerce-Site ohne Antwort
überprüfte ich die curl_error
und es scheint, wird der folgende Fehler zu sein:
< HTTP/1.1 301 Moved Permanently..
Dies ist der Beispielcode
<?php
$api_url = 'site url/api/v2/blog/posts/count';
$fp = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept:application/json','Content-Length: 0'));
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR, $fp);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_USERPWD, "username:passwd");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
Dank viel @Victor T. –