【问题标题】:How do I call mongodb rest api through curl in php?如何在php中通过curl调用mongodb rest api?
【发布时间】:2013-04-04 12:22:54
【问题描述】:

因为我的英语不好就处决我。

我是mongolab的新手。我想知道如何通过php中的curl调用mongolad rest api。

我不想使用 mongodb 驱动。

提前致谢。

【问题讨论】:

    标签: php curl mlab


    【解决方案1】:

    试试这个(将 myApiKey 替换为 MongoLab 的 api 密钥):

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://api.mongolab.com/api/1/databases?apiKey=myAPIKey");
    curl_setopt($ch, CURLOPT_USERAGENT, "MongolabBot/1.0");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);
    curl_close($ch);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-09
      • 2020-04-12
      • 1970-01-01
      • 2015-11-17
      • 1970-01-01
      • 2016-12-19
      • 2016-09-12
      相关资源
      最近更新 更多