views:

121

answers:

2

I've been able setup the oAuth calls to get the users access Token following a couple blog posts:

http://sudheerkovalam.wordpress.com/2010/08/28/a-windows-phone-7-twitter-application-part-1/ and :/byatool.com/c/connect-your-web-app-to-twitter-using-hammock-csharp/comment-page-1/#comment-9955

But I'm having problems sending a status update. I can't find any examples so I may not be setting the proper values. Here's the code which keeps returning: "Could not authenticate with OAuth."

private void Tweet()
{
    var credentials = new OAuthCredentials
                            {
                                Type = OAuthType.ProtectedResource,
                                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                                ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
                                ConsumerKey = TwitterSettings.ConsumerKey,
                                ConsumerSecret = TwitterSettings.ConsumerKeySecret,
                                Token = _settings.AccessToken,
                                TokenSecret = _settings.AccessTokenSecret,
                                Version = TwitterSettings.OAuthVersion,
                            };

    var client = new RestClient
    {
        Authority = "http://twitter.com/oauth",
        Credentials = credentials,
        HasElevatedPermissions = true
    };

    var request = new RestRequest
    {
        Path = "/statuses/update.json",
        Method = WebMethod.Post
    };

    request.AddParameter("status", TwitterTextBox.Text);

    client.BeginRequest(request, new RestCallback(TwitterPostCompleted));
}

private void TwitterPostCompleted(RestRequest request, RestResponse response, object userstate)
{
    Dispatcher.BeginInvoke(() => MessageBox.Show(response.Content));
}

thanks for any help, Sam

+1  A: 

Ah figured it out finally I was using the wrong URL need to use:

Authority = "http://api.twitter.com" and not: "http://twitter.com/oauth"

related questions