Skip to content

Commit 1bc1ce2

Browse files
committed
Fix a bug that can't post an image to Twitter #194
* Twitter Model: Update UPLOAD_API_URL Close #194
1 parent d5e9fb9 commit 1bc1ce2

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

xpi/chrome/content/library/models.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ Models.register(update({
11701170
ORIGIN : 'https://twitter.com',
11711171
ACCOUT_URL : 'https://twitter.com/settings/account',
11721172
TWEET_API_URL : 'https://twitter.com/i/tweet',
1173-
UPLOAD_API_URL : 'https://upload.twitter.com/i/media/upload.iframe',
1173+
UPLOAD_API_URL : 'https://upload.twitter.com/i/media/upload.json',
11741174
STATUS_MAX_LENGTH : 140,
11751175
OPTIONS : {
11761176
// for twttr.txt.getTweetLength()
@@ -1413,17 +1413,13 @@ Models.register(update({
14131413
var bis = new BinaryInputStream(new FileInputStream(file, -1, 0, false));
14141414

14151415
return request(this.UPLOAD_API_URL, {
1416-
responseType : 'document',
1416+
responseType : 'json',
14171417
sendContent : update({
14181418
media : btoa(bis.readBytes(bis.available()))
14191419
}, token)
14201420
}).addErrback(() => {
14211421
throw new Error(getMessage('message.model.twitter.upload'));
1422-
}).addCallback(({response : doc}) => {
1423-
var json = JSON.parse(doc.scripts[0].textContent.extract(
1424-
/parent\.postMessage\(JSON\.stringify\((\{.+\})\), ".+"\);/
1425-
));
1426-
1422+
}).addCallback(({response : json}) => {
14271423
return this.update(update({
14281424
media_ids : json.media_id_string
14291425
}, token), status);

0 commit comments

Comments
 (0)