【问题标题】:Posting image to twitter using Twitter+OAuth使用 Twitter+OAuth 将图像发布到 Twitter
【发布时间】:2012-04-22 04:02:53
【问题描述】:

我在我的应用程序中使用 Twitter+OAuth ...我已成功发布消息或文本。但我还必须发布图片...所以请指导我完成这项工作。

【问题讨论】:

    标签: iphone objective-c twitter-oauth


    【解决方案1】:

    这是一个 HTTP POST 到 Twitter 的样子,使用 update_with_media.xml

    您的应用必须以特定于 您的应用程序,考虑令牌、令牌秘密等。

    有一些特定于平台的库可以帮助生成 Authorization 标头的值。例如,在 .NET 中,有 an open-source OAuth.Manager class 来实现这一点。

    POST https://upload.twitter.com/1/statuses/update_with_media.xml HTTP/1.1
    Authorization: OAuth oauth_callback="oob", oauth_consumer_key="FXJ0DIH50S7ZpXD5HXlalQ", oauth_nonce="7774328k", oauth_signature="pUYjRnccmrBYiO1j9cliETsw%2B5s%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1318300521", oauth_token="59152613-vrlZ2edX56PudQtBmpAWd3SPDt9cPyAhibO7ysl6W", oauth_version="1.0"
    Content-Type: multipart/form-data; boundary=======c49479438c600bf59345e======
    Host: upload.twitter.com
    Content-Length: 7320
    Connection: Keep-Alive
    
    --======c49479438c600bf59345e======
    Content-Disposition: form-data; name="status"
    
    working on a Tweet tool that uses the OAuth Manager library.
    --======c49479438c600bf59345e======
    Content-Disposition: file; name="media[]"; filename="ThisIsAPicture.png"
    Content-Type: image/png
    
      ...binary png data here...
    
    --======c49479438c600bf59345e======--
    

    【讨论】:

      【解决方案2】:

      易于使用的共享工具包http://getsharekit.com/

      NSString *imageTitle = @"图片标题";

      SHKItem *item = [SHKItem image:UIImage title:imageTitle];

      [SHKTwitter shareItem:item];

      【讨论】:

        猜你喜欢
        • 2012-10-06
        • 2016-09-12
        • 2013-03-14
        • 2015-04-24
        • 1970-01-01
        • 2013-01-15
        • 2010-12-01
        • 2013-05-04
        • 1970-01-01
        相关资源
        最近更新 更多