【问题标题】:Posting a Curl request through php通过 php 发布 Curl 请求
【发布时间】:2017-11-21 11:59:26
【问题描述】:

我想向 pilosa 数据库发送一个发布请求。请求是这样的-

curl localhost:10101/index/user/query -X 发布 -d '位图(frame="language", id=5)'。

如何通过 php 发送以下请求?

参考链接:https://www.pilosa.com/docs/api-reference/

【问题讨论】:

标签: php curl post


【解决方案1】:

如果您没有可用的php curl 库,您可以使用php 的file_get_contents 查询Pilosa,它是核心php 的一部分。以下 php 脚本应执行您的示例查询:

<?php

$url = 'http://localhost:10101/index/user/query';
$data = 'Bitmap(frame="language", id=5)';

$options = array(
    'http' => array(
        'method'  => 'POST',
        'content' => $data
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);

var_dump($result);

?>

Pilosa HTTP API 文档位于:https://www.pilosa.com/docs/api-reference/

【讨论】:

    猜你喜欢
    • 2017-04-23
    • 2015-12-06
    • 2022-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多