Reputation: 103
Hi I'm trying to get data from anther site so I used
$url = 'MY_URL' . $route . '/' . $id;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('url: ACCESS_URL', 'token: TOKEN'));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, $type);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$output = curl_exec($ch);
curl_close($ch);
return $output;
so I get 301 Moved Permanently output I works fine on local machine put after uploading I got that error ,any suggestions
Upvotes: 0
Views: 884
Reputation:
You need to specifically tell cURL to follow redirection:
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
Upvotes: 0
Reputation: 103
the problem with me was missing component curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
Upvotes: 2