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

Uploading Media: Code 220 #138

Open
superjoefly opened this issue Aug 25, 2017 · 1 comment
Open

Uploading Media: Code 220 #138

superjoefly opened this issue Aug 25, 2017 · 1 comment

Comments

@superjoefly
Copy link

superjoefly commented Aug 25, 2017

I've been trying to upload media (small images) to Twitter, but the "media_upload" call has been producing an error: (code: 220, message: "Your credentials do not allow access to this resource.)

This is the code I'm using to convert the image to base64:

encodeImageFileAsURL(e) {
      let input = event.target;
      if (input.files && input.files[0]) {
        let file = input.files[0];
        let reader = new FileReader()
        reader.onloadend = function() {
          window.store.state.selectedImage = reader.result.substr(reader.result.indexOf(',') + 1);
        }
        reader.readAsDataURL(file);
      }
   }

And this is the code I've been using for the call:

    var params = {
      "media_data": state.selectedImage
    };

    cb.__call(
      "media_upload",
      params,
      function(reply, rate, err) {
          console.log(reply.media_id_string);     // => undefined
      }
    )

Any suggestions on how to approach this?

Sidenote: all my other calls to the twitter api are working.

Thanks for your help :-)

@mynetx
Copy link
Member

mynetx commented Sep 15, 2018

@superjoefly Are you accessing media_upload using application-only auth or from within a user context on full OAuth with access token?

@mynetx mynetx self-assigned this Sep 15, 2018
@mynetx mynetx added this to the 3.0 “Calverley” milestone Sep 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants