Skip to content

Commit

Permalink
Fix a bug that can't post an image to Twitter #194
Browse files Browse the repository at this point in the history
* Twitter Model: Update UPLOAD_API_URL

Close #194
  • Loading branch information
syoichi committed May 21, 2015
1 parent d5e9fb9 commit 1bc1ce2
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions xpi/chrome/content/library/models.js
Expand Up @@ -1170,7 +1170,7 @@ Models.register(update({
ORIGIN : 'https://twitter.com',
ACCOUT_URL : 'https://twitter.com/settings/account',
TWEET_API_URL : 'https://twitter.com/i/tweet',
UPLOAD_API_URL : 'https://upload.twitter.com/i/media/upload.iframe',
UPLOAD_API_URL : 'https://upload.twitter.com/i/media/upload.json',
STATUS_MAX_LENGTH : 140,
OPTIONS : {
// for twttr.txt.getTweetLength()
Expand Down Expand Up @@ -1413,17 +1413,13 @@ Models.register(update({
var bis = new BinaryInputStream(new FileInputStream(file, -1, 0, false));

return request(this.UPLOAD_API_URL, {
responseType : 'document',
responseType : 'json',
sendContent : update({
media : btoa(bis.readBytes(bis.available()))
}, token)
}).addErrback(() => {
throw new Error(getMessage('message.model.twitter.upload'));
}).addCallback(({response : doc}) => {
var json = JSON.parse(doc.scripts[0].textContent.extract(
/parent\.postMessage\(JSON\.stringify\((\{.+\})\), ".+"\);/
));

}).addCallback(({response : json}) => {
return this.update(update({
media_ids : json.media_id_string
}, token), status);
Expand Down

0 comments on commit 1bc1ce2

Please sign in to comment.