【问题标题】:How to upload image saved in local device to Instagram Graph API如何将保存在本地设备中的图像上传到 Instagram Graph API
【发布时间】:2023-02-20 20:46:56
【问题描述】:

我想使用 Facebook Graph API 在 Instagram 上发帖。要发布图像,它需要保存在公共服务器中的图像的 URL。下面是我正在使用的 python 代码 -

def postInstagram(): post_url = "https://graph.facebook.com/my_id/media"

payload = {
    "image_url": image_url,
    "caption": my_caption,
    "access_token": my_token}
r = requests.post(post_url, data=payload)

result = json.loads(r.text)
if 'id' in result:
    creation_id = result['id']

    second_url = "https://graph.facebook.com/v13.0/my_id/media_publish"
    second_payload = {
        "creation_id": creation_id,
        "access_token": "my_token"
    }
    r = requests.post(second_url, data=second_payload)

但我想直接通过从我的本地设备上传图片而不是通过 URL 来发布图片。我不知道该怎么做。请帮我。

【问题讨论】:

  • 该文档没有提到这是可能的,所以假设它不是。

标签: python facebook-graph-api instagram-graph-api


【解决方案1】:

官方文档说 URL 应该是公开的

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-03
    • 1970-01-01
    • 2015-03-28
    • 2013-01-10
    • 2019-01-20
    • 1970-01-01
    • 1970-01-01
    • 2018-02-12
    相关资源
    最近更新 更多