【问题标题】:Send Data From PHP CURL [closed]从 PHP CURL 发送数据 [关闭]
【发布时间】:2014-05-16 23:02:46
【问题描述】:

我需要向 URL 发送一些表单数据 (POST)。

但我不希望我的剧本交给她。

我有一个数据库中的用户列表,我需要花费http://www.somesite.com/receive

除了我的脚本不能去那里。

是否可以在不离开页面的情况下发出 POST 请求? (不使用 Ajax)。

类似 CURL 的东西?

【问题讨论】:

  • 到目前为止你编码了什么?这个网站是关于真实代码中的真实问题的。
  • 服务端可以使用curl,客户端可以使用ajax。

标签: php post curl


【解决方案1】:

您的问题有点难以理解。如果我有足够的代表,我会在评论中要求澄清,但我不能。

您只是想使用 curl 发送 HTTP POST 请求吗?如果是这样,您可以使用PHP's curl functions,确保将 CURLOPT_POST 设置为 true。这段代码来自another question

$ch = curl_init();
$curlConfig = array(
    CURLOPT_URL            => "http://www.example.com/yourscript.php",
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS     => array(
        'field1' => 'some date',
        'field2' => 'some other data',
    )
);
curl_setopt_array($ch, $curlConfig);
$result = curl_exec($ch);
curl_close($ch);

// result sent by the remote server is in $result

这里有some 更多references

【讨论】:

    猜你喜欢
    • 2013-12-24
    • 1970-01-01
    • 2010-12-28
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 2011-11-16
    • 2022-08-19
    • 2010-11-08
    相关资源
    最近更新 更多