curl returning 301 error after migrating to https curl returning 301 error after migrating to https curl curl

curl returning 301 error after migrating to https


You need to follow the redirect using the CURLOPT_FOLLOWLOCATION option:

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);

From the documentation:

TRUE to follow any "Location: " header that the server sends as part of the HTTP header (note this is recursive, PHP will follow as many "Location: " headers that it is sent, unless CURLOPT_MAXREDIRS is set).

Or you can simply use https:// in your code to avoid the redirect.