Note that there are some explanatory texts on larger screens.

plurals
  1. POUpload photo to Facebook from Silverlight
    text
    copied!<p>I have recently starting porting a small app of mine to Facebook as a learning experience. I'm quite familiar with Silverlight and .NET in general but haven't done anything on facebook yet. Since all the SDKs and APIs that are available seem to not work, or I wasn't able to use them properly, I decided to directly access Facebook's Graph API and it have been easy so far (I can login, ask for permissions, get profile, albums and photos and post to the users feed). Now I want to upload a photo and this is where I'm really hitting a wall. I use something like this to post a feed:</p> <pre><code> WebClient client = new WebClient(); client.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadStringCompleted); client.UploadStringAsync(new Uri(String.Format("https://graph.facebook.com/me/feed")), "POST", String.Format("message={0}&amp;link={1}&amp;picture={2}&amp;access_token={3}", "Test", "www.gong.bg", "http://gong.bg/uploads/teams/teams_logos/logo_small_1.png", this.Access_Token)); </code></pre> <p>Quite simple, but it works fine and I don't need more.</p> <p>For uploading photos I tried to use similar code but with no success, then I decided to try with HttpWebRequest and I now have the following:</p> <pre><code> HttpWebRequest request = (HttpWebRequest)WebRequest.Create(String.Format("https://graph.facebook.com/me/photos")); request.ContentType = "multipart/form-data"; request.Method = "POST"; request.BeginGetRequestStream(ar =&gt; { using (StreamWriter writer = new StreamWriter((ar.AsyncState as HttpWebRequest).EndGetRequestStream(ar))) { writer.Write("{0}={1}&amp;", "message", HttpUtility.UrlEncode("Test")); writer.Write("{0}=@{1}&amp;", "source", HttpUtility.UrlEncode("3.png")); writer.Write("{0}={1}&amp;", "access_token", this.Access_Token); } }, request); </code></pre> <p>This is not working and I cannot see where the problem is. According to Facebook documentation this should upload a photo to the app default album (create one if doesn't exist)</p> <p>Thanks all.</p>
 

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