1

I'm setting up the back end for an Android/iOS app that, among other things, allows users to share an image via Twitter. It's hosted on Heroku, which has no local image hosting, so the images are hosted elsewhere.

It looks like if you want to tweet an image you're supposed to POST to /statuses/update_with_media and send the image as multi-part data. But I don't have the images stored locally, so I would have to copy the image over to temp storage on Heroku, POST it to Twitter, and then delete it, which seems... inefficient.

Is there any way I can use Twitter's API to tweet an image and only supply the URL for the image?

4

1 回答 1

1

看起来不可能通过他们的 API 向 Twitter 发送链接,大概是因为他们必须自己下载图像。您可以将图像上传到第三方并链接到该图像,但在这种情况下您会遇到同样的问题。

不过,您不需要复制文件,您可以将文件读入内存并将其序列化为多部分表单数据,以便发送到 Twitter。

你有任何代码要显示吗?

于 2013-04-30T22:17:54.793 回答