【问题标题】:Error "Unable to parse response, not valid JSON" when using non English tags on Instagram API在 Instagram API 上使用非英文标签时出现“无法解析响应,无效 JSON”错误
【发布时间】:2015-08-07 10:54:15
【问题描述】:

我正在尝试使用 Python 获取有关带有西里尔文标签的 Instagram 照片的信息:

# -*- coding: utf-8 -*-

from instagram import client, subscriptions
from instagram.client import InstagramAPI

api = InstagramAPI(client_id = 'XX', client_secret = 'XX')
p = api.tag_recent_media(tag_name = 'ночь')
for media in p:
    print(media)

它与英文标签(例如'cats')完美配合,但与西里尔文一样失败:

InstagramClientError: (500) Unable to parse response, not valid JSON.

尝试了Unicode编码\解码等技巧,但失败了。

如何处理非英文标签?

【问题讨论】:

    标签: python instagram instagram-api


    【解决方案1】:

    你应该可以用非英文字符查询Instagram API,我可以做到。

    您收到此错误可能是因为您的请求不包含access_token,您应该像这样启动 API 对象:

    api = client.InstagramAPI(access_token=access_token, client_secret=client_secret)
    

    在 Github 存储库中的 sample_app.py 上查看更多使用此 API 的示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多