Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook Album Picture using Facebook C# SDK
    text
    copied!<p>I'm tring to get an album picture from facebook using the facebook C# SDK within Silverlight app with the following code:</p> <pre><code> FacebookClient client = new FacebookClient(this.Profile.AccessToken); client.GetAsync(string.Format("/{0}/picture?type=small", this.ID)); client.GetCompleted += (s, e) =&gt; { dynamic result = e; }; </code></pre> <p>Where this.ID is the ID of the album, but I get this error: Unexpected character encountered while parsing value: �. Line 1, position 1. from the DeserializeObject method in the JsonSerializer. The problem is that facebook does'n return json data with the imge uri or something like this, but they actually return the image itself in a binary data. Anybody has any idea how I can handle this result or just get Uri to the image? I have a workaround for this using this code:</p> <pre><code> var request = WebRequest.Create(string.Format("https://graph.facebook.com/{0}/picture?access_token={1}", this.ID, this.Profile.AccessToken)); request.BeginGetResponse(ar =&gt; { using (var response = ((WebRequest)ar.AsyncState).EndGetResponse(ar)) { Deployment.Current.Dispatcher.BeginInvoke(() =&gt; { this.Picture = new BitmapImage(new Uri(response.ResponseUri.AbsoluteUri)); } ); } }, request); </code></pre> <p>But I really wanted to use only Facebook C# SDK for getting the data.</p> <p>Here is the solution that I'm going to use:</p> <pre><code> FacebookClient client = new FacebookClient(this.Profile.AccessToken); client.QueryAsync(String.Format("SELECT src_small, src_big, src FROM photo WHERE pid IN (SELECT cover_pid FROM album WHERE object_id={0})", this.ID)); client.GetCompleted += (s, e) =&gt; { dynamic result = e.GetResultData(); Deployment.Current.Dispatcher.BeginInvoke(() =&gt; this.Picture = result[0].src_small); }; </code></pre>
 

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