Reputation: 43
I'm trying to get the location of Instagram pictures from my account. The API is giving me all sorts of information about my account and pictures, but when I try to get the location of my pictures it says:
Trying to get property of non-object in ....
My code looks like this:
foreach($phplijst->data as $data){
echo "<img src=" . $data->images->low_resolution->url . " />";
echo "<p>" . $data->location->longitude . "</p>";
}
The first "echo" gives me all the images from my account. The second "echo" is supposed to give me the longitude of all the images on my account. Instead it gives me that error message. Does anyone know how to fix this?
Upvotes: 0
Views: 603
Reputation: 43
Never mind guys! I've fixed it. I forgot to add a location to my images so that's why I didn't get a location :) Thanks for the help anyway!
Upvotes: 0
Reputation: 20909
It means that $data->location
isn't an object.
You should check your object structure with var_dump($data)
and verify it has the layout you expect.
Upvotes: 1