0

I'm trying to access appannie.com's api. I can't seem to get past the authentication. Here's what I have, any thoughts?

<?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;

?>

Here's a link to their api docs: http://appannie.zendesk.com/categories/20082753-Analytics-API http://support.appannie.com/entries/23215057-2-Authentication

Dev01
  • 13,292
  • 19
  • 70
  • 124

2 Answers2

1

For those finding this VIA google, this code no longer works as of November 21, 2013. AppAnnie deprecated basic authentication of HTTP.

You will now need to apply for an API key located at https://www.appannie.com/account/api/key/

Once you have the API key, you can use the following code to authenticate yourself on 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;
?>
Velkyr
  • 373
  • 4
  • 9
0

The code you posted works (tested it myself). It returned (for a newly created account): {"page_index": 0, "code": 200, "account_list": [], "prev_page": null, "page_num": 1, "next_page": null} Keep in mind that $whmusername is your AppAnnie emailaddress and not a username.

jabbink
  • 1,271
  • 1
  • 8
  • 20
  • Really! Man, now I feel really stupid. All I get is blank page... I'm going to try to run it on my local machine and see if it works. – Dev01 May 15 '13 at 22:41