Pour commencer, je suis un tout petit apprenti du codage.
Je suis occuper à créer une page qui fait appel au résulta du api pour la liste des amis sur steam.
Le résulta que je reçois sont tout les IP des comptes, exemple:
................
{
"friendslist": {
"friends": [{
"steamid": "76561197964486200",
"relationship": "friend",
"friend_since": 1472499278
}, {
"steamid": "76561197969552760",
"relationship": "friend",
"friend_since": 1523988328
}, {
"steamid": "76561197970160876",
"relationship": "friend",
"friend_since": 1382522811
}, {
"steamid": "76561197977737009",
"relationship": "friend",
"friend_since": 1456859464
},
ext
Donc maintenant j'ai les résultats mais j'ai besoin de les placer en ordre exemple :
https://www.w3schools.com/html/exercise ... se_tables1
Mais je comprend pas vraiment quelle chemin prendre, voici le codage:
_______________________________________________
$apifr = "http://api.steampowered.com/ISteamUser/GetFriendList/v0001/?key=".$value1."&steamid=".$value2."&relationship=friend";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$apifr);
$result=curl_exec($ch);
curl_close($ch);
$datafr =json_decode($result, true); //Decoding the JSON. The "true" parameter indicates we will use them in an array
$count = 0; //This "count" var will count the total amount of friends in the JSON
foreach($datafr['friendslist']['friends'] as $friend) { //We need a foreach because we dont know the number of friends
$friends[$count] = $friend['steamid']; //This will add each steam id into an array "friends"
$count++;
}
for ($i = 0; $i < $count; $i++) { //Now we have the array and the number of elements so we can print them with a for
echo $friends[$i]." <br/>";}
_______________________________________________Pourriez-vous me montrer quelle-que exemple svp ?
Merci d'avance !
