Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [json][php] odczyt pliku json i wyświetlenie w php, pobieranie danych z pliku do sygnatury
sznoorek
post
Post #1





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 21.12.2006

Ostrzeżenie: (0%)
-----


Witam!
Potrzebuje pomocy, chce pobrać dane z pliku który z tego co wiem jest w formacie json.
Zawartośc zdalnego pliku:
Kod
{
  "status": "ok",
  "status_code": "NO_ERROR",
  "data": {
    "achievements": {
      "medalCarius": 3,
      "medalHalonen": 0,
      "medalPascucci": 0,
      "invader": 0,
      "medalFadin": 0,
      "armorPiercer": 1,
      "medalEkins": 0,
      "mousebane": 0,
      "mechanicEngineer": false,
      "medalBrunoPietro": 0,
      "heroesOfRassenay": 0,
      "medalKay": 4,
      "evileye": 0,
      "tankExperts": {
        "usa": false,
        "france": false,
        "ussr": false,
        "china": false,
        "uk": false,
        "germany": false
      },
      "defender": 1,
      "medalLeClerc": 3,
      "supporter": 0,
      "medalTamadaYoshio": 0,
      "steelwall": 0,
      "bombardier": 0,
      "medalAbrams": 3,
      "medalBrothersInArms": 0,
      "maxDiehardSeries": 3,
      "medalPoppel": 3,
      "medalOrlik": 0,
      "maxKillingSeries": 4,
      "handOfDeath": 1,
      "medalTarczay": 0,
      "sinai": 0,
      "sniper": 1,
      "warrior": 0,
      "titleSniper": 1,
      "maxInvincibleSeries": 3,
      "medalCrucialContribution": 0,
      "medalDeLanglade": 0,
      "medalWittmann": 0,
      "medalBurda": 0,
      "maxPiercingSeries": 9,
      "scout": 0,
      "beasthunter": 0,
      "kamikaze": 0,
      "medalRadleyWalters": 0,
      "raider": 0,
      "medalNikolas": 0,
      "medalOskin": 0,
      "medalBillotte": 0,
      "medalLavrinenko": 4,
      "medalKolobanov": 0,
      "invincible": 0,
      "lumberjack": 0,
      "medalBoelter": 0,
      "tankExpert": 0,
      "diehard": 0,
      "medalLafayettePool": 0,
      "mechanicEngineers": {
        "usa": false,
        "france": false,
        "ussr": false,
        "china": false,
        "uk": false,
        "germany": false
      },
      "medalLehvaslaiho": 0,
      "medalDumitru": 0,
      "maxSniperSeries": 17,
      "medalKnispel": 3
    },
    "ratings": {
      "spotted": {
        "place": 759270,
        "value": 406
      },
      "dropped_ctf_points": {
        "place": 945790,
        "value": 159
      },
      "battle_avg_xp": {
        "place": 555893,
        "value": 209
      },
      "xp": {
        "place": 771174,
        "value": 92787
      },
      "battles": {
        "place": 839663,
        "value": 444
      },
      "damage_dealt": {
        "place": 733203,
        "value": 88326
      },
      "ctf_points": {
        "place": 884903,
        "value": 529
      },
      "integrated_rating": {
        "place": 697870,
        "value": 4
      },
      "battle_avg_performance": {
        "place": 1088643,
        "value": 45
      },
      "frags": {
        "place": 783394,
        "value": 231
      },
      "battle_wins": {
        "place": 854002,
        "value": 200
      }
    },
    "name": "Neomagic",
    "created_at": 1327841290.0,
    "vehicles": [
      {
        "spotted": 0,
        "localized_name": "SU-85B",
        "name": "GAZ-74b",
        "level": 4,
        "damageDealt": 0,
        "survivedBattles": 0,
        "battle_count": 106,
        "nation": "ussr",
        "image_url": "/static/2.1.2/encyclopedia/tankopedia/vehicle/small/ussr-gaz-74b.png",
        "frags": 0,
        "win_count": 56,
        "class": "AT-SPG"
      },
      {
        "spotted": 0,
        "localized_name": "T-28",
        "name": "T-28",
        "level": 4,
        "damageDealt": 0,
        "survivedBattles": 0,
        "battle_count": 94,
        "nation": "ussr",
        "image_url": "/static/2.1.2/encyclopedia/tankopedia/vehicle/small/ussr-t-28.png",
        "frags": 0,
        "win_count": 42,
        "class": "mediumTank"
      },
      {
        "spotted": 0,
        "localized_name": "KW-1",
        "name": "KV1",
        "level": 5,
        "damageDealt": 0,
        "survivedBattles": 0,
        "battle_count": 75,
        "nation": "ussr",
        "image_url": "/static/2.1.2/encyclopedia/tankopedia/vehicle/small/ussr-kv1.png",
        "frags": 0,
        "win_count": 24,
        "class": "heavyTank"
      },
      {
        "spotted": 0,
        "localized_name": "T-46",
        "name": "T-46",
        "level": 3,
        "damageDealt": 0,
        "survivedBattles": 0,
        "battle_count": 45,
        "nation": "ussr",
        "image_url": "/static/2.1.2/encyclopedia/tankopedia/vehicle/small/ussr-t-46.png",
        "frags": 0,
        "win_count": 21,
        "class": "lightTank"
      },
      {
        "spotted": 0,
        "localized_name": "SU-76",
        "name": "SU-76",
        "level": 3,
        "damageDealt": 0,
        "survivedBattles": 0,
        "battle_count": 31,
        "nation": "ussr",
        "image_url": "/static/2.1.2/encyclopedia/tankopedia/vehicle/small/ussr-su-76.png",
        "frags": 0,
        "win_count": 16,
        "class": "AT-SPG"
      },
      {
        "spotted": 0,
        "localized_name": "T-50",
        "name": "T-50",
        "level": 4,
        "damageDealt": 0,
        "survivedBattles": 0,
        "battle_count": 31,
        "nation": "ussr",
        "image_url": "/static/2.1.2/encyclopedia/tankopedia/vehicle/small/ussr-t-50.png",
        "frags": 0,
        "win_count": 14,
        "class": "lightTank"
      },
      {
        "spotted": 0,
        "localized_name": "SU-85",
        "name": "SU-85",
        "level": 5,
        "damageDealt": 0,
        "survivedBattles": 0,
        "battle_count": 25,
        "nation": "ussr",
        "image_url": "/static/2.1.2/encyclopedia/tankopedia/vehicle/small/ussr-su-85.png",
        "frags": 0,
        "win_count": 9,
        "class": "AT-SPG"
      },
      {
        "spotted": 0,
        "localized_name": "KW-2",
        "name": "KV2",
        "level": 6,
        "damageDealt": 0,
        "survivedBattles": 0,
        "battle_count": 20,
        "nation": "ussr",
        "image_url": "/static/2.1.2/encyclopedia/tankopedia/vehicle/small/ussr-kv2.png",
        "frags": 0,
        "win_count": 10,
        "class": "heavyTank"
      },
      {
        "spotted": 0,
        "localized_name": "T-26",
        "name": "T-26",
        "level": 2,
        "damageDealt": 0,
        "survivedBattles": 0,
        "battle_count": 8,
        "nation": "ussr",
        "image_url": "/static/2.1.2/encyclopedia/tankopedia/vehicle/small/ussr-t-26.png",
        "frags": 0,
        "win_count": 4,
        "class": "lightTank"
      },
      {
        "spotted": 0,
        "localized_name": "AT-1",
        "name": "AT-1",
        "level": 2,
        "damageDealt": 0,
        "survivedBattles": 0,
        "battle_count": 6,
        "nation": "ussr",
        "image_url": "/static/2.1.2/encyclopedia/tankopedia/vehicle/small/ussr-at-1.png",
        "frags": 0,
        "win_count": 3,
        "class": "AT-SPG"
      },
      {
        "spotted": 0,
        "localized_name": "MS-1",
        "name": "MS-1",
        "level": 1,
        "damageDealt": 0,
        "survivedBattles": 0,
        "battle_count": 3,
        "nation": "ussr",
        "image_url": "/static/2.1.2/encyclopedia/tankopedia/vehicle/small/ussr-ms-1.png",
        "frags": 0,
        "win_count": 1,
        "class": "lightTank"
      }
    ],
    "updated_at": 1352126066.0,
    "battles": {
      "spotted": 406,
      "hits_percents": 48,
      "capture_points": 529,
      "damage_dealt": 88326,
      "frags": 231,
      "dropped_capture_points": 159
    },
    "summary": {
      "wins": 200,
      "losses": 237,
      "battles_count": 444,
      "survived_battles": 74
    },
    "experience": {
      "xp": 92787,
      "battle_avg_xp": 209,
      "max_xp": 1107
    },
    "clan": {
      "member": null,
      "clan": null,
      "clan_ext": null
    }
  }
}


Dane które będą pobranę chce nałożyć na obrazek (PHP + GD).

Niestety nie miałem żadnego kontaktu z json, który jest porównywalny do xml'a.
Jakby ktoś dał przykład w jaki sposób pobrać dane typu:
Kod
"place": 759270,
"value": 406
"spotted": 0,
"localized_name": "T-50",
"name": "T-50",
"level": 4,
"damageDealt": 0,
"survivedBattles": 0,
"battle_count": 31,
"nation": "ussr",
"image_url": "/static/2.1.2/encyclopedia/tankopedia/vehicle/small/ussr-t-50.png",
"frags": 0,
"win_count": 14,
"class": "lightTank"


Z góry dziekuję, nawet za nakierownia jak to zrobić.
Aktualnie mam skrypt PHP który wyszukje te dane z html'a, ale nie wszytskie dane są tam pokazywane.

Ten post edytował sznoorek 14.11.2012, 20:42:50
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 26.09.2025 - 23:51