I'm working in python-3.3 using Instagram Developer API's User Endpoint to grab recent media from one of the people I follow.
response = requests.get(URL).json()
test = response["data"]
return HttpResponse(test, "text/html")
Gives me content in data[...] portion in my equivalent of the example response.
However, I can't seem to access contents deeper than that.
For example,
response = requests.get(URL).json()
test = response["data"]
return HttpResponse(test[0], "text/html")
Gives me a list of the next keys:
"typecreated_timeuserattributionfilterusers_in_photocaptionlikestagslinkimagesiduser_has_likedcommentslocation"
While:
response = requests.get(URL).json()
test = response["data"]
return HttpResponse(test["images"], "text/html")
Gives me an exception: "list indices must be integers, not str"
I can also do for each look and the like with:
response = requests.get(URL).json()
test = response["data"]
for test in response["data"]:
for image in test["images"]:
HttpResponse(image["low_resolution"], "text/html")
return HttpResponse(test["images"], "text/html")
etc, which will continue to return the key names until such a point like above which gives me an error "string indices must be integers".
If I wished to access, for example, data->(first block)->images->low_resolution->url, how should I go about doing this?
Thanks in advance.
I found that response['data'][0]['images']['low_resolution']['url'] will get you to low resolution in the json.