2013-03-16 59 views
0

我尝试卷曲的URL在我的代码的网页,但卷曲不工作,我有卷曲链接的onclick按钮

$url="http://merimobiles.com/cart.php?action=add&product_id=9949" 
echo file_get_contents($url); 

测试,它使没有发现错误, 卷曲代码从curl_init,curl_setopt,curl_exec这里

$ch = @curl_init(); 
@curl_setopt($ch, CURLOPT_URL, $url); 
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_REFERER,$url); 
$response = @curl_exec($ch); 
@curl_close($ch); 
echo $response; 

回答

0

删除@,并检查错误:

$response = curl_exec($ch); 
if ($response === false) { 
    echo 'Curl error: ' . curl_error($ch); 
} 
+0

它显示的回波部分卷曲的错误:但不会返回它需要的任何错误 – Shahbaz 2013-03-16 11:01:55

0

我看到了什么这个网址

http://merimobiles.com/cart.php?action=add&product_id=9949 

是重定向到

http://www.merimobiles.com/cart.php?suggest=51444ec01e7a2 

您应该设置卷曲选项

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
+0

但在该页面上显示错误 在此服务器上未找到请求的URL /templates/__custom/lib/shipping_schedule/shipping-1-text.html。 – Shahbaz 2013-03-16 11:03:48

+0

是的,因为它是iframe。在这种情况下,我会解析文档并在'/ templates/__ custom/lib/shipping_schedule/shipping-1-text.html'前添加'http:// www.merimobiles.com' – 2013-03-16 11:11:27