Sorry za odgrzewanie tematu ale mam podobny problem (z tą samą stroną)
Jak otrzymać dane poszczególnych graczy w przypadku jak każdy gracz jest zapisany jako rekord w tablicy?
Dane są na stronie:
http://clan.z8games.com/clanstat_cf.aspx?guildid=179955
W tym przypadku zapytanie wysyłam pod adres:
http://clan.z8games.com/clanServices.asmx/getClanMembers
postem wysyłam dane:
{"clanid":"179955"}
a otrzymuję:
{"d":"[{"usn":7742375,"nick":"Gianni94","lev":17,"clan_points":130,"memberType":"9"},{"usn":8657341,"nick":"bobydick105","lev":17,"clan_points":110,"memberType":"8"},{"usn":12927224,"nick":"c0munista","lev":8,"clan_points":21,"memberType":"0"},{"usn":13227749,"nick":"LostNemesis","lev":6,"clan_points":13,"memberType":"0"},{"usn":9423004,"nick":"Italiano17","lev":4,"clan_points":4,"memberType":"0"}]"}
W poprzednim przypadku nie ma problemu bo jest tylko jeden gracz z unikatowymi danymi ale tutaj jest już tablica graczy. Co zrobić żeby osobno otrzymać dane każdego gracza?
Próbowałam czegoś takiego (wzorowałam się na pierwszym przykładzie):
<?php
$useragent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2';
$accept = 'application/json, text/javascript, */*; q=0.01';
$contenttype = 'application/json; charset=utf-8';
$xrequestedwith = 'XMLHttpRequest';
$clanid = "179955";
$ckfile = tempnam("/tmp", "CURLCOOKIE");
$ch = curl_init("http://clan.z8games.com/clanstat_cf.aspx?guildid=" . $clanid);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$ch = curl_init('http://clan.z8games.com/clanServices.asmx/getClanMembers');
curl_setopt($ch,CURLOPT_HTTPHEADER,
array
(
"Accept: " . $accept,
"X-Requested-With: " . $xrequestedwith,
"Content-Type: " . $contenttype
));
curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://clan.z8games.com/clanstat_cf.aspx?guildid=" . $clanid);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array("clanid"=>$clanid)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$responsearray = json_decode($response,true);
$data = json_decode($responsearray["d"],true);
$usn=$data['usn'];
echo $usn;
?>
W którym miejscu robię błąd?