Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用类似curl的用户访问url_Php_Curl - Fatal编程技术网

Php 使用类似curl的用户访问url

Php 使用类似curl的用户访问url,php,curl,Php,Curl,我有一个购物车,我想要一个curl函数将产品添加到购物车中,它是在用户单击“添加到购物车”链接时添加的,但我尝试了许多curl函数,购物车仍然是空的: 我的代码: $url = 'The href of the add to cart button when click on it the product added to the cart'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($cur

我有一个购物车,我想要一个curl函数将产品添加到购物车中,它是在用户单击“添加到购物车”链接时添加的,但我尝试了许多curl函数,购物车仍然是空的:

我的代码:

$url = 'The href of the add to cart button when click on it the product added to the cart';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$data = curl_exec($curl);
curl_close($curl);

如果你不提供实际地址,那就很难了。也许您必须在登录后保存cookie,然后使用CURLOPT_cookie