Instagram API docs无效的JSON错误

时间:2015-12-25 10:38:27

标签: python json instagram instagram-api

当我尝试python-instagram文档中的示例时,我一直收到此错误:

from instagram.client import InstagramAPI

access_token = "YOUR_ACCESS_TOKEN"
client_secret = "YOUR_CLIENT_SECRET"
api = InstagramAPI(access_token=access_token, client_secret=client_secret)
recent_media, next_ = api.user_recent_media(user_id="userid", count=10)
for media in recent_media:
   print media.caption.text

错误:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/instagram/bind.py", line 197, in _call
    return method.execute()
  File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/instagram/bind.py", line 189, in execute
    content, next = self._do_api_request(url, method, body, headers)
  File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/instagram/bind.py", line 131, in _do_api_request
    raise InstagramClientError('Unable to parse response, not valid JSON.', status_code=response['status'])
InstagramClientError: (404) Unable to parse response, not valid JSON.

我不确定导致此错误的原因。我得到了access_token并填写了所有参数

当我尝试文档的其他部分时,我得到了同样的错误:

api = InstagramAPI(client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET')
popular_media = api.media_popular(count=20)
for media in popular_media:
    print media.images['standard_resolution'].url

1 个答案:

答案 0 :(得分:0)

11月11日,Ig在11月17日进行了一些主要的平台更改(引入沙盒模式),可能会影响您的访问。

我会从你正在使用的回购中查看this thread,还有很多SO链接。

建议绕过python API并使用curl这样的内容来编写注释(看看你是否可以缩小错误):

curl -F 'access_token=ACCESS-TOKEN' \
 -F 'text=This+is+my+comment' \
 https://api.instagram.com/v1/media/{media-id}/comments