Note that there are some explanatory texts on larger screens.

plurals
  1. POStoring Facebook likes locally - Fetching number of likes performance issue
    primarykey
    data
    text
    <p>I am building an app using ASP.NET 4.0. </p> <p>I have a table called entries. Entries can be liked via Facebook. I want to implement the ability to sort via likes so I am taking the approach of storing the number of likes for each entry and using that column to order. The problem is the overhead involved in getting the number of likes. I think the method I am using could be improved as right now because fetching data for only 13 entries is taking 4 seconds, which is way too long. </p> <p>I am using the FB graph api and <a href="http://james.newtonking.com/projects/json-net.aspx" rel="nofollow">JSON.NET</a> to parse the response. In the following code I have a List of type Entry, I am getting the like url for the entry using an app setting combined with the entries id. This is what I am doing:</p> <pre><code> foreach (Entry entry in entries) { int likes; try { // the url that is tied to the entry string url = "http://graph.facebook.com/?ids=" + Properties.Settings.Default.likeUrl + "?id=" + entry.EntryId; //open a WebClient and get the results of the url WebClient client = new WebClient(); Stream data = client.OpenRead(url); StreamReader reader = new StreamReader(data); string s = reader.ReadToEnd(); //parse out the response var json = JObject.Parse(s); //shares are how many likes the entry has likes = Convert.ToInt32(json.First.First.SelectToken("shares").ToString()); } catch (Exception ex) { likes = 0; } } </code></pre> <p>As I said this method is very expensive. If anyone could suggest a better way to do what I am attempting here I would really appreciate the help. Thanks much!</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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