【问题标题】:Upload image to twitter using update_with_media - Lua使用 update_with_media - Lua 将图像上传到 Twitter
【发布时间】:2012-06-28 10:49:28
【问题描述】:

我正在尝试使用 update_with_media.json 将图像发布到 Twitter。

以下是使用 statuses/update.json 更新推文的工作代码

local url = "http://api.twitter.com/1/statuses/update.json"
local consumer_key = ""
local consumer_secret = ""
local token = ""
local token_secret = ""


local post_data = 
    {
    oauth_consumer_key = consumer_key,
    oauth_nonce        = get_nonce(),
    oauth_signature_method = "HMAC-SHA1",
    oauth_token        = token,
    oauth_timestamp    = get_timestamp(),
    oauth_version      = '1.0',
    oauth_token_secret = token_secret

    }

post_data["status"] = "Hello Twitter!"      
post_data = oAuthSign(url, "POST", post_data, consumer_secret)


r,c,h = http.request
   {
   url = url,
   method = "POST",
   headers = 
         {
         ["Content-Type"] = "application/x-www-form-urlencoded", 
         ["Content-Length"] = string.len(rawdata)
         },
   source = ltn12.source.string(post_data),
   sink = ltn12.sink.table(response)
   }

现在如何修改上面的代码来上传图片? 该网址将是“http://api.twitter.com/1/statuses/update_with_media.json”和 headers["Content-Type"] 将是 "multipart/form-data"

但是我在哪里以及如何指定要上传的图像?

【问题讨论】:

    标签: lua twitter twitter-oauth


    【解决方案1】:

    好的,我在一段时间前得到了这个工作.. 这个帖子by velluminteractive 提供了一个很好的库来处理 twitter。

    诚然,该代码用于名为 Corona SDK 的游戏引擎。但是,通过从中删除特定于 Corona 的元素,对其他人来说使用起来应该不会太难。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-28
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 1970-01-01
      • 2015-01-10
      • 2016-09-09
      • 2012-09-26
      相关资源
      最近更新 更多