Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $url = "http://api.cyberrepublik.com/citizens/".$id;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $file = curl_exec($ch);
- $xml = new SimpleXMLElement($file);
- if ((int)$xml->id === 0 || (string)$xml->name === "") {
- /* nie ma takiego gracza */
- }
- $id = (int)$xml->id;
- $nick = (string)$xml->name;
- $exp = (int)$xml->exp;
- $well = (int)$xml->wellness;
- $bday = strtotime((string)$xml->birthday);
- $lvl = (int)$xml->level;
- $company = (int)$xml->company;
- $minfo = $xml->{'military-info'};
- $mrank = (int)$minfo->{'military-rank'};
- $dmg = (int)$minfo->{'total-dmg'};
- $hits = (int)$minfo->{'total-hits'};
- foreach ($xml->skills->military->skill as $skill) {
- $skills["military"][(string)$skill->name] = (int)$skill->points;
- }
- foreach ($xml->skills->economy->skill as $skill) {
- $skills["economy"][(string)$skill->name] = (int)$skill->points;
- }
- $residence = (string)$xml->residence->region->name;
- $residenceid = (int)$xml->residence->region->id;
- $country = (string)$xml->residence->country->name;
- $cid = (int)$xml->residence->country->id;
- $party = (string)$xml->politics->party;
- $pstatus = (string)$xml->politics->status;
- foreach ($xml->medals->medal as $medal) {
- $medals[(string)$medal->name] = (int)$medal->amount;
- }
- /* output danych */
Advertisement
Add Comment
Please, Sign In to add comment