javascript - Get facebook comment by id -


i have facebook comment box. want store comment in database when user comments something. attaching callback function fb.event.subscribe('comment.create', ... there commentid , href way exact comment fql deprecated 2011 , nobody knows when facebook remove it. using graph api can comments there no way find out comment belongs specific user of our app (we don't ask permissions there no access_token; trigger popup form when comments important match user details comment (that's why subscribe comment.create)). there smart way or should rely on deprecated feature?

edit:

i trying comment this:

fb.api(         {             method: 'fql.query',             query: "select text, fromid comment post_fbid = '" + resp.commentid +                 "' , object_id in (select comments_fbid link_stat url='" + resp.href + "')"         },         function (data) {             var fb_id                 , comment              console.log(data)              if ( data.length == 1 ) {                 fb_id = data[0].fromid                 comment = data[0].text             }          // ...       } ) 

the problem when on localhost - returns array 1 element - comment want. when upload app - returns array no elements. maybe there permission issues. question how content of comment when submitted. canonical way? possible without access_token , permissions?

fql isn't deprecated. blog post talking rest api specifically, later on states changes fql.

to access comments need valid access token can view top level object. assuming comments on websites, normal extended page access token should suffice following scenario 5 explained @ https://developers.facebook.com/roadmap/offline-access-removal/

https://graph.facebook.com/oauth/access_token?                  client_id=app_id&     client_secret=app_secret&     grant_type=fb_exchange_token&     fb_exchange_token=existing_access_token  

exchange short-lived user access token long-lived access token using endpoint , steps explained earlier. using long-lived user access token, querying [user id]/accounts endpoint provide page access tokens not expire pages user manages.

then using page access token [user id]/accounts can pretty hard code in (you can create own backend login tool, in event invalidate token 1 day or need change it) via server side language example php using php sdk

$facebook->setaccesstoken('your_page_token'); 

so here can ajax post php page sdk loaded

window.fbasyncinit = function(){ fb.event.subscribe('comment.create',     function(response) {         oncommentcreate(response.commentid);     } );  function oncommentcreate(commentid) {     $.ajax({         type: 'post',         url: 'createcomment.php',         data: {commentid:commentid},         success: function(result)         {             alert(result);         }     }); }  } 

and request comment information there

<?php  if ($_server['request_method'] == 'post' && isset( $_post['commentid'] ))  {  $commentid = $_post['commentid'];  require 'facebook.php';  $facebook = new facebook(array(     'appid'  => 'app_id_here',     'secret' => 'app_secret_here', ));  $facebook->setaccesstoken('your_page_token');  $response = $facebook->api($commentid);  echo $response['from']['id'];  } ?> 

an example of can seen @ http://philippeharewood.com/facebook/experiments/createcomment.html

references


Comments