2013-05-15 80 views
0

我試圖訪問appannie.com的api。我似乎無法通過身份驗證。這是我的,有什麼想法?Appannie 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

回答

0

您發佈作品的代碼(測試它自己)。它返回(對於新創建的帳戶):{"page_index": 0, "code": 200, "account_list": [], "prev_page": null, "page_num": 1, "next_page": null} 請記住,$ whmusername是您的AppAnnie電子郵件地址,而不是用戶名。

+0

真的!男人,現在我覺得很愚蠢。我得到的只是空白頁面......我將嘗試在本地機器上運行它,看看它是否有效。 –

1

對於那些發現此威盛谷歌的用戶,此代碼不再適用於2013年11月21日。AppAnnie不推薦使用HTTP的基本認證。

現在,您將需要申請所在的API密鑰在https://www.appannie.com/account/api/key/

一旦你的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; 
?>