oauth-io / oauth-phonegap

OAuth.io plugin for Apache Cordova/PhoneGap
195 stars 69 forks source link

Twitter Post Not Working #12

Closed carlos-oli closed 10 years ago

carlos-oli commented 10 years ago

Hi,

I am trying to send a status update to twitter using the oauth-phonegap plugin, but it is failing to send. The authentication step is successful but when it tries to do the post I receive a 400 error saying that there is an invalid origin or header.

I have replicated the error using the Example solution, with the following index.html:

    <script type="text/javascript">
        $(document).on('deviceready', function() {
            OAuth.initialize("nQ5IntIg0oMEWtYkDOFEtPWsdL8");

            $('#tw-connect').on('click', function() {
                $('#result').html("");
                OAuth.popup("twitter", function(e,r) {
                    if (e)
                        $('#result').html('error: ' + e.message);
                    else
                            r.post({
                                     url: '/1.1/statuses/update.json',
                                     data: { status: $scope.shareMessage }
                                     }).done(function(data) {
                                             $('#result').html("Posted");
                                             });
                });
            });
        });
    </script>

Please could you let me know what I am doing wrong?

Thanks

bumpmann commented 10 years ago

It seems phonegap was sending an origin file:// for post requests so we added a fallback on localhost. I tested with your example (with something different than $scope.shareMessage) and seems to work now.

Sorry for the inconvenient. This error was server side so you don't need to update the phonegap sdk, but the last version fixes the authorization timeout issue https://github.com/oauth-io/oauthd/issues/47 ) so you may update it.

murugarajans commented 9 years ago

carlosatshaping

hi, have you succeeds in attempt of posting tweets on twitter through this method?