1

我正在尝试使用 cURL 将发布数据发送到特定文件,但似乎不起作用。我有语法错误还是我过早关闭 curl?有没有好的方法来测试它并查看我发送的变量。

$my_url = 'http://www.website.com/file.php';
              $post_vars = 'custom_id1=' .$cid. '&custom_id2=' .$cid2. '&invoice_id=' .$invoiceid. '&amount=' .$amount;

              $curl = curl_init($my_url);
              curl_setopt($curl, CURLOPT_POST, 1);
              curl_setopt($curl, CURLOPT_POSTFIELDS, $post_vars);
              curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
              curl_setopt($curl, CURLOPT_HEADER, 0);
              curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

              $response = curl_exec($curl);

              curl_close($curl);
4

1 回答 1

1

cURL 语法错误试试这个

<?php
$my_url = 'http://www.website.com/file.php';
$post_vars = 'custom_id1=' .$cid. '&custom_id2=' .$cid2. '&invoice_id=' .$invoiceid. '&amount=' .$amount;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $my_url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_vars);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($curl);
curl_close($curl);
?>
于 2013-06-08T10:40:10.807 回答