Here's my scenario. I have an external URL : https://staging.mead.com.ph/login/sso Now I have to post data to that URL, assuming like the one below :
- Name
- Type
- Mobile Num
Now, after posting I have to be redirected to the [redirect_url] inside curl_getinfo(). [redirect_url] has the following value : https://staging.mead.com.ph/login/key=abcde
HOWEVER,after echoing the result of the curl_exec, it says "Object Moved Here" and "HERE" redirects to https://myservername/login/key=abcde instead of the https://staging.mead.com.ph/login/key=abcde
Here's my code :
$url = "https://staging.mead.com.ph/login/key=abcde";
$token = "token1234";
$params = array(
"Name" => "Ana",
"Type" => "A",
"Mobilenum" => "0919123456"
);
foreach($params as $key => $value) {
$fields .= $key . '=' . $value . '&';
}
rtrim($fields, '&');
$post = curl_init();
curl_setopt($post, CURLOPT_URL, $url);
curl_setopt($post, CURLOPT_POST, count($params));
curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($post, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($post, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($post, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($post, CURLOPT_PROXYUSERPWD, PROXY_AUTH);
curl_setopt($post, CURLOPT_PROXY, PROXY_URL);
curl_setopt($post, CURLOPT_PROXYPORT, PROXY_PORT);
curl_setopt($post, CURLOPT_TIMEOUT,6);
$result = curl_exec($post);
echo $result;
curl_close($post);
What could be wrong? Thanks in advance.