首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Appannie api基本身份验证

Appannie api基本身份验证
EN

Stack Overflow用户
提问于 2013-05-16 05:26:55
回答 2查看 2.1K关注 0票数 0

我正在尝试访问appannie.com的api。我似乎无法通过认证。这就是我的想法,有什么想法吗?

代码语言:javascript
复制
<?php

$whmusername = "username";
$whmpassword = "password";

$query = "https://api.appannie.com/v1/accounts";

$ch = curl_init();
// Sets the URL cURL will open
curl_setopt($ch, CURLOPT_URL, $query);
// Here's the HTTP auth
// The 3rd argument is your Twitter username and password joined with a colon
curl_setopt($ch, CURLOPT_USERPWD, $whmusername.":".$whmpassword);
// Makes curl_exec() return server response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// And here's the result XML
$response = curl_exec($ch);
curl_close($ch);
print $response;

?>

下面是他们的api文档的链接:http://appannie.zendesk.com/categories/20082753-Analytics-API http://support.appannie.com/entries/23215057-2-Authentication

EN

回答 2

Stack Overflow用户

发布于 2014-02-05 00:02:23

对于那些通过谷歌找到这个的人来说,这个代码从2013年11月21日起不再起作用。AppAnnie不推荐使用HTTP的基本身份验证。

您现在需要申请一个位于https://www.appannie.com/account/api/key/的API密钥。

获得API密钥后,您可以使用以下代码在AppAnnie上进行身份验证:

代码语言:javascript
复制
<?php
$query = "https://api.appannie.com/v1/accounts";

$ch = curl_init();
// Sets the URL cURL will open
curl_setopt($ch, CURLOPT_URL, $query);
// Here's the HTTP auth
// The 3rd argument is your Twitter username and password joined with a colon
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: bearer API_KEY'));
// Makes curl_exec() return server response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// And here's the result XML
$response = curl_exec($ch);
curl_close($ch);
print $response;
?>
票数 1
EN

Stack Overflow用户

发布于 2013-05-16 05:50:42

您发布的代码工作正常(我自己测试了它)。它返回(对于新创建的帐户):{"page_index": 0, "code": 200, "account_list": [], "prev_page": null, "page_num": 1, "next_page": null}请记住,$whmusername是您的AppAnnie电子邮件地址,而不是用户名。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16575242

复制
相关文章

相似问题

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