从javascript/Jquery twitter上传媒体文件和文本状态



如何仅从客户端将图像和状态上传到Twitter。我正在使用 Oauth.io 和Phonegap。如果有人知道这件事,请尽快回复我。

看看这个jsfiddle: http://jsfiddle.net/6Jx84/12/

OAuth.popup("twitter").then(function(result) {
    var data = new FormData();
    data.append('status', 'This is a test');
    data.append('media[]', b64toBlob(logo), 'logo.png');
    return result.post('/1.1/statuses/update_with_media.json', {
        data: data,
        cache:false,
        processData: false,
        contentType: false
    });
}).done(function(data){
    //todo once the image is sent
}).fail(function(e){
    //todo if an error occured
});

它发送一条状态为"这是一个测试"和OAuth.io徽标的推文

它使用 Twitter API 的端点/1.1/statuses/update_with_media.json:https://dev.twitter.com/rest/reference/post/statuses/update_with_media

最新更新