Facebook comments count in fbml doesn't work anymore -


so can't comment count work using html5 boxes:

html:

<fb:comments-count href="http://example.com"></fb:comments-count> comments 

js sdk included this:

<script>(function(d, s, id) {         var js, fjs = d.getelementsbytagname(s)[0];         if (d.getelementbyid(id)) return;         js = d.createelement(s); js.id = id;         js.src = "//connect.facebook.net/en_us/sdk.js#xfbml=1&appid=233176953542656&version=v2.0";         fjs.parentnode.insertbefore(js, fjs);     }(document, 'script', 'facebook-jssdk'));</script> 

and.. instead of querying normal graph comments endpoint executed fql query https://graph.facebook.com/v2.0/fql?callback... in response gave this:

/**/ fb.__globalcallbacks.f2670b77d1e44b({     "error": {         "message":"an access token required request resource.",         "type":"oauthexception",         "code":104     } }) 

so either have use iframe method load comment count (10s of iframes per page.. it's lot in opinion) or ask user auth on facebook see comment number?

isn't there way other writing own wrapper call graph api?

for wrote own graph wrapper:

html:

<a href="http://example.com">             <span class="ext-fb-comments-count" data-href="http://example.com"></span> comments </a> 

graph wrapper put end of template:

<script>     (function(){         var items = {};         var urls = [];         $('.ext-fb-comments-count').each(function(){             var obj = $(this);             var href = obj.data('href');             items[ href ] = obj;             urls.push(encodeuri(href));         });         urls.length && $.get('http://graph.facebook.com/?ids=' + urls.join(','), null, function(r){                 for(key in r) items[key].html( r[key].comments?r[key].comments:'0' );             });     })(); </script> 

it looks elements class 'ext-fb-comments-count' , if finds - loads comment count them.

demo here: http://jsfiddle.net/2u54q/

live result: http://dyatlovprojects.com/startups/


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -