Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Twitter OAuth1Request sample code

$
0
0

Has anyone done a successful tweet with media in Xamarin?

I have managed to tweet a message, but just a message without OAuth1Request. But when I have to post a photo following this doc I'm getting an error.

Here is my code:

` IDictionary<string,string> test= new Dictionary<string,string>(); Random rand = new Random(); int random = rand.Next(0,100);

            string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            string combinedPath = Path.Combine(path,extension);

            byte[] bytes=ImageConverter.ReadImage (combinedPath);

            test.Add("status", "something "+random);

            test.Add("media[]",System.Text.Encoding.UTF8.GetString(bytes));


            var request = new Xamarin.Auth.OAuth1Request("POST", new Uri("https://api.twitter.com/1.1/statuses/update_with_media.json"),test,accounts.ElementAt(0),false);


            request.GetResponseAsync().ContinueWith (t => {
                if (t.IsFaulted) 
                    Console.WriteLine("Error: " + t.Exception.InnerException.Message);
                else if (t.IsCanceled)
                    Console.WriteLine("Canceled");
                else
                {
                    Console.WriteLine("Sent "+random);
                }
            }, uiScheduler);

`

The error info is just "One or more errors occured", so I'm lost...


Viewing all articles
Browse latest Browse all 204402

Trending Articles