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 に答える