我正在尝试访问appannie.com的api。我似乎无法通过认证。这就是我的想法,有什么想法吗?
<?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
发布于 2014-02-05 00:02:23
对于那些通过谷歌找到这个的人来说,这个代码从2013年11月21日起不再起作用。AppAnnie不推荐使用HTTP的基本身份验证。
您现在需要申请一个位于https://www.appannie.com/account/api/key/的API密钥。
获得API密钥后,您可以使用以下代码在AppAnnie上进行身份验证:
<?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;
?>发布于 2013-05-16 05:50:42
您发布的代码工作正常(我自己测试了它)。它返回(对于新创建的帐户):{"page_index": 0, "code": 200, "account_list": [], "prev_page": null, "page_num": 1, "next_page": null}请记住,$whmusername是您的AppAnnie电子邮件地址,而不是用户名。
https://stackoverflow.com/questions/16575242
复制相似问题