Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have worked out a solution for this, by using the Hammock.WindowsPhone.Mango library. (TweetSharp internally uses Hammock library for oAuth and other functionalities, but I have never used TweetSharp or Twitterizer)</p> <p>I have installed the latest version of Hammock from <a href="http://nuget.org/packages/Hammock">Nuget</a></p> <p>And then the following code is used for photo upload to Twitter:</p> <pre><code>public void uploadPhoto(Stream photoStream, string photoName) { var credentials = new OAuthCredentials { Type = OAuthType.ProtectedResource, SignatureMethod = OAuthSignatureMethod.HmacSha1, ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, ConsumerKey = TwitterSettings.consumerKey, ConsumerSecret = TwitterSettings.consumerKeySecret, Token = TwitterSettings.accessToken, TokenSecret = TwitterSettings.accessTokenSecret, Version = "1.0a" }; RestClient restClient = new RestClient { Authority = "https://upload.twitter.com", HasElevatedPermissions = true, Credentials = credentials, Method = WebMethod.Post }; RestRequest restRequest = new RestRequest { Path = "1/statuses/update_with_media.json" }; restRequest.AddParameter("status", tbxNewTweet.Text); restRequest.AddFile("media[]", photoName, photoStream, "image/jpg"); } restClient.BeginRequest(restRequest, new RestCallback(PostTweetRequestCallback)); } private void PostTweetRequestCallback(RestRequest request, Hammock.RestResponse response, object obj) { if (response.StatusCode == System.Net.HttpStatusCode.OK) { //Success code } } </code></pre> <p>Here, photoName is the name of the image selected ( "e.OriginalFileName") photoStream is the "e.ChosenPhoto" from the PhotoChooserTask</p> <p>and the 4th parameter for .AddFile() should be taken care (I have not considered other formats while doing this sample, you have to take care in your apps)</p> <p>I hope this helps!!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload