Domanda

Sto ricevendo questo tipo di risposta da Instagram Server.

{
    "meta": {
        "code": 200
    },
    "data": {
        ...
    },
    "pagination": {
        "next_url": "...",
        "next_max_id": "13872296"
    }
}
.

Come posso ottenere i "dati" - parte? Ho provato a decodificare JSON in PHP come:

//$userfeed is giving me something like above.
$tried_this = json_decode($userfeed['meta']);
.

Ma $userfeed e $tried_this sembrano essere uguali.

Aggiornamento Giù di seguito sono i dati reali ...

Ho lasciato fuori il token di accesso, ma altrimenti è corretto. Questa è solo una parte di essa, ma spero che tu abbia il quadro ....

.

{"Pagination": {"next_url": "https://api.instagram.com/v1/users/3/media/recent?access_token=Blablabla\22026Max_id=622063574553989866_3", "next_max_id": "622063574553989866_3 }, "Meta": {"Codice": 200}, "Dati": [{"Attribution": Null, "Tag": [], "Tipo": "Immagine", "Posizione": {"Latitude": 21.367158921, "Nome": "Pali Lookout "," longitudine ": - 157.79304912," ID ": 60507}," Commenti ": {" Conte ": 313," Dati ": [{" creato_time ":" 1401835727 "," Testo ":" Mi dai un grido Out "," da ": {" username ":" nick_putukian1 "," profilo_picture ":" http://images.ak.instagram.com/profiles/profile_1370615750_75sq_14014535573.jpg "," ID ":" 1370615750 "," full_name ":" Nicholas Putukian "}," ID ":" 734973811849433422 "}, {" creato_time ":" 1401836165 "," Testo ":" I ne ho solo uno Follower "," Da ": {" nome utente ":" nick_putukian1 "," profilo_picture ":" http://images.ak.instagram.com/profiles/profile_1370615750_75sq_14014535573.jpg "," id ":" 1370615750 "," full_name ":" Nicholas Putukian "}," ID ":" 734977485287985692 "}, {" creato_time ":" 1401837312 "," Testo ":" Caro @kevin potresti aggiungere una funzione di condivisione su IG? Quindi gli utenti non devono Screenshot a foto prima se vogliamo condividerlo. Grazie. "," "Da": {"username": "natalia.igaa", "profilo_picture": "http://images.ak.instagram.com/profiles/profile_1003500786_75sq_1401603184.jpg", "ID": "1003500786" , "full_name": "Ayu Natalia "}," ID ":" 734987110351638699 "}, {" creato_time ":" 1401837882 "," Testo ":" Ciao Kevin "," Da ": {" username ":" GildatheGriffon "," PROFILE_PICCURE ":" http://images.ak.instagram.com/profiles/profile_320785380_75sq_1401448420.jpg "," ID ":" 320785380 "," full_name ":" Dovidi "}," ID ":" 734991884560110057 "}, {" creato_time ":" 1401838561 "," Testo ":" \ ud83d \ ude02 \ ud83d \ ude02 \ ud83d \ ude02 \ ud83c \ udf42 \ udd83c \ udf42 \ ud83d \ udc9

Perdonami per non averti dato un "Leggible" Var_Dump, ma per qualche motivo il var_dump su un server specifico che sto provando non lo rende leggibile come previsto.

$data = json_decode($userfeed, true);
var_dump($data['data']);
.

Sta tornando NULL

È stato utile?

Soluzione

Supponendo, una stringa JSON valida, faresti:

$data = json_decode($json_string, true);
var_dump($data['data']);
.

Altri suggerimenti

Lets assume that you have provided access_token, than following syntax will meet your requirements

$url          =   "https://api.instagram.com/v1/users/3/media/recent/?access_token=ACCESS-TOKEN";
$content      =   file_get_contents($url);
$data         =   json_decode($content, true);
var_dump($data['data']);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top