首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >卷曲问题

卷曲问题
EN

Stack Overflow用户
提问于 2015-11-12 19:51:52
回答 1查看 187关注 0票数 0

嗨,我正在尝试使用推车 api接口来获取我的应用程序的分析。问题是我不太懂卷发或者如何实现它。

我希望有人能解释我如何使用我贴在下面的代码。

代码语言:javascript
复制
curl -X GET \
-H "x-pushbots-appid: xxxxxxxxxxxxxxxxxxxxxxx" \
-H "x-pushbots-secret: xxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
https://api.pushbots.com/analytics

编辑:我现在使用的是代码

代码语言:javascript
复制
<?php
$headers = array("Content-Type: application/json","x-pushbots-appid: XXXXXXXXXXXXXX","x-pushbots-secret: XXXXXXXXXXXXXXXXXXXXXX");

$appid = "x-pushbots-appid: XXXXXXXXXXXXXXXXXXXXXXXXX";
$secretid = "x-pushbots-secret: XXXXXXXXXXXXXXXXXXXXXXX";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"api.pushbots.com/analytics");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $appid&$secretid);


curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//set the headers now
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);

curl_close ($ch);

var_dump($output);


?>

我现在看到了这个错误:

代码语言:javascript
复制
string(64) "{"code":"MethodNotAllowedError","message":"POST is not allowed"}" 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-12 20:02:28

1)。使用GETcURL请求发送到:- https://api.pushbots.com/analytics

2)。您需要发送的数据字段是x-pushbots-appidx-pushbots-secret

3)。标题应该是Content-Type: application/json

下面是一个简单的例子。

代码语言:javascript
复制
<?php
$headers = "Content-Type: application/json";
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"https://api.pushbots.com/analytics");
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); 
curl_setopt($ch, CURLOPT_POSTFIELDS,
            "x-pushbots-appid=somevalue&x-pushbots-secret=somevalue");


curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//set the headers now
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);

curl_close ($ch);

var_dump($output);
?>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33680123

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档