Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twitter Media Upload not working #54

Closed
douglascorrea opened this issue Feb 9, 2015 · 5 comments
Closed

Twitter Media Upload not working #54

douglascorrea opened this issue Feb 9, 2015 · 5 comments

Comments

@douglascorrea
Copy link

I´m trying to use oauth client to upload media to Twitter using 1.1 API but I´m receiving 404 if I use the result.post method:

r.post('/1.1/media/upload.json', {
      data: {
        media: imgBase64
      }
    })

I receive:

Failed to load resource: the server responded with a status of 404 (Not Found)
https://oauth.io/request/twitter/%2F1.1%2Fmedia%2Fupload.json

I know that media/upload.json uses diferent domain as endpoint:
upload.twitter.com

more details here: https://dev.twitter.com/rest/reference/post/media/upload

@douglascorrea
Copy link
Author

I saw that oauth.io update home page and received newsletter about new features and so on. It means these issue will be considered? (At least some feedback about)?

@thyb
Copy link
Contributor

thyb commented Nov 19, 2015

The issue is the endpoint you call is on upload.twitter.com while oauth.io is actually making a call to api.twitter.com when you're giving a relative endpoint.

You can try with this:

r.post('https://upload.twitter.com/1.1/media/upload.json', { 
   data: {
       media_data: imgBase64
   }
})

btw, note that if you're using base64 file to upload, you need to use media_data and not media which is used for raw data file.

I got normal response using this:

{"media_id":667134289646133248,"media_id_string":"667134289646133248","size":793,"expires_after_secs":86400,"image":{"image_type":"image\/png","w":16,"h":16}}

@thyb thyb closed this as completed Nov 19, 2015
@dlittle42
Copy link

I'm trying to upload media to twitter as well. I tried using this endpoint, but I keep getting this error:

XMLHttpRequest cannot load https://oauth.io/request/twitter/%2F1.1%2Fmedia%2Fupload.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 413.

@JeffGreat
Copy link

I'm having the same response status 413. My file is a bit more than 1Mo. It works with a smaller file. I dont understand why the request is too long since the Twitter Api documentation is talking about 5Mo limitation.

@JeffGreat
Copy link

The chunk method is prefered by twitter. Therefore I've finally adapted my code and it works thanks to this code I adapted:
https://github.com/jambonsw/twitter-media-upload-split-error-mve/blob/gh-pages/main.js#L110

If you need more info let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants