0
我不知道如何從輸出中獲取所有的gamertags,然後將它們插入到mysql表中。插入遊戲歷史記錄頁面中的所有遊戲者標籤。
這是我到目前爲止,閱讀評論...謝謝!
<?php
//gameID
$gameid = "469547013";
//key to access api
$apikey = "30cRxVA9J73esG388CzmOXUVRo5VjYhSfI2qBaqcMzs=";
$url = "http://www.bungie.net/api/reach/reachapijson.svc/game/details/".$apikey."/".$gameid."";
$output = file_get_contents($url);
$obj = json_decode($output);
//output
print_r($output);
//json_decoded output
print_r($obj);
//Having a hard time getting a single gamertag
print $obj->GameDetails->Players->PlayerDetail[0]->gamertag;
//I guess there needs to be an array or arrays here
$result = ????????????;
while ($tag = $result) {
//value
$tag = $array['gamertag'];
//insert each gamertag into table
mysql_connect('localhost', '', '') or die('Error connecting to MySQL');
mysql_select_db('');
mysql_query("INSERT IGNORE INTO gamertags(gamertag)VALUES ('".$tag."')");
}
?>
而不是暴露你的API密鑰給大家,怎麼樣粘貼一些示例數據? – drudge 2011-02-08 20:06:46
輸出超過了一個職位的限制,我不想從網站鏈接..鑰匙將被改變... – AndrewFerrara 2011-02-08 20:11:50