Facebook - migrating fb:comments from href to xid? [duplicate] - facebook

I've integrated fb:comments using the href parameter, but I am now stuck in a situation where I need to retrieve the comment count without fb:comment-count.
I normally use an FQL query such as below...
$result = $facebook->api(array(
'query' => 'SELECT post_id FROM comment WHERE xid = "' . $xid . '"',
'method' => 'fql.query'));
$comment_count = count($result);
However, there is no href column present in the comment table. Is there another way to do this? I have tried seeing if xid and href are interchangeable... no luck there. I'm also finding that fb:comments plugins created with xid id's are breaking a lot on me (see http://65beta.us/fb/fb1.php ).
Any advice would be greatly appreciated. Thanks!

You can easily reach comment and like counts like this: http://graph.facebook.com/?ids=http://65beta.us/fb/fb1.php

Related

How to display just students in users page(Moodle:/admin/user.php)

I want to display just students in moodle users page without manually adding a filter using the web interface. Could anybody help me on how to do?
You can create a link that shows only students but you'll need to post the data. Here's how I did it.
If you install WebDeveloper - http://chrispederick.com/work/web-developer/
Then go to /admin/user.php and click WebDeveloper, choose the "Forms" tab and "convert POSTS to GETS".
Choose the filter and click add filter. This will display a url with all the form fields. Moodle is expecting a POST rather than a GET though.
So copy and paste the url into a variable and use the single_button function with the post method eg:
$url = '/admin/user.php?sesskey=xxxxxxx&_qf__user_add_filter_form=1&mform_showmore_id_newfilter=1&mform_isexpanded_id_newfilter=1&realname_op=0&realname=&lastname_op=0&lastname=&firstname_op=0&firstname=&email_op=0&email=&city_op=0&city=&country_op=0&confirmed=&suspended=&profile_fld=0&profile_op=0&profile=&courserole_rl=5&courserole_ct=0&courserole=&systemrole=0&cohort_op=2&cohort=&username_op=0&username=&auth=&deleted=&addfilter=Add+filter';
echo $OUTPUT->single_button($url, get_string('student'), 'post');
Copy and paste your own url rather than the above.
You can probably remove a lot of the parameters. You should also get the roleid for the student and use the moodle_url function, eg:
$studentroleid = $DB->get_field('role', 'id', array('shortname' => 'student'));
$params = array('courserole_rl' => $studentroleid, 'courserole_ct' => 0, ... );
$url = new moodle_url('/admin/user.php', $params);
echo $OUTPUT->single_button($url, get_string('students'), 'post');
This is not possible, as, in Moodle, it is rare for someone to be assigned the role of 'student' at the system level (and if you did, they would have access to every course on the site).
The concept of 'student' in Moodle only makes sense at the course level.

comment.create event gives me an useless comment id because I cannot make a query with it [duplicate]

I am using Facebook comment box plugin:
<fb:comments href="${myPageUrl}" num_posts="20" width="630"></fb:comments>
Every thing is working fine. The problem is that I want to store the comment posted into my database. Is there any way to fetch the text posted on the comment box.
I am using the following js to catch comment-create event.
FB.Event.subscribe('comment.create', function(response) {
alert(response.commentID)
});
I'm getting some commentId from this but I don't know how to fetch the exact comment posted on a particular comment-create event.
Coomie: Actually whenever a comment is posted, I catch the event thru 'comment.create'. I was able to catch the event but I was wondering how to get the comment(text) posted at that particular event. Like event.text or event.comment but there was no direct method found
So, now I am manipulating it with fql. Which is somewhat similar to you example. First retrieving the whole list and then selecting the top one.
My sample code is below:
FB.Event.subscribe('comment.create', function(response) {
FB.api({
method: 'fql.query',
query: "SELECT post_fbid, fromid, object_id, text, time from comment WHERE object_id in (select comments_fbid from link_stat where url ='${PageUrl}') order by time desc limit 1"
},
function(response) {
var feed = response[0];
alert(feed.text)
});
});
So this method is giving me exactly the same result I want.
I don't have the complete answer but this should get you on your way.
You can use the facebook graph api to extract information about an open graph id (an open graph id is FB's way of identifying a person, website, application or URL). Eg. this page:
http://www.inhousegroup.com.au/newsroom/23-best-practice-for-advanced-seo/ (the place that fired me)
uses a comment box. The web page has an open id of 10150441190653416. So when you comment on this page facebook sees your comment as a wall post on that page's "wall".
Using the graph api, you can get some JSON info about the page here:
http:/graph.facebook.com/10150441190653416
And you can get the posts from this address:
http://graph.facebook.com/10150441190653416/posts
But you'll have to get an access token.
Then you just have to import the posts on save and compare your db to the JSON and add records as neccessary.
Good luck!
FB.Event.subscribe('comment.create', function(response) {
var commentQuery = FB.Data.query('SELECT fromid, text FROM comment WHERE post_fbid=\'' + response.commentID + '\' AND object_id IN (SELECT comments_fbid FROM link_stat WHERE url=\'' + response.href + '\')');
FB.Data.waitOn([commentQuery], function () {
text = commentQuery.value[0].text;
// Use your preferred way to inform the server to save comment
$.post( 'http://example.com/comment', text )
});
});

facebook open graph parameter

I have a code in index.php file like below:
$ret_obj = $facebook->api('/me/vanlelu:cook?food=http://fabubu.com/MKK/exam/cookie1.php', 'post',);
And a file cookie1.php.
They are all working well (can post activity to wall of tester account).
But, i wondering is there any way to send parameters to cookie1.php.
I have tryed this but its not working:
$ret_obj = $facebook->api('/me/vanlelu:cook?food=http://fabubu.com/MKK/exam/cookie1.php?para=123456', 'post',);
Please help....
Updated:
have find one solution like below:
$ret_obj = $facebook->api('/me/vanlelu:cook', 'post',array('food' => 'http://fabubu.com/MKK/exam/cookie1.php?id=1234678'));
Now, the file 'cookie1.php' can $_GET['id'] by value '1234678'.
But when i change the value '1234678', this api command not work well, even i change parameter.
Not working: $ret_obj = $facebook->api('/me/vanlelu:cook', 'post',array('food' => 'http://fabubu.com/MKK/exam/cookie1.php?id=1234678888888888888'));
Not working: $ret_obj = $facebook->api('/me/vanlelu:cook', 'post',array('food' => 'http://fabubu.com/MKK/exam/cookie1.php?iddddddddddd=1234678'));
It seem facebook open graph remember exactly my parameter and its value. When i change one of them, its got error.
Could you make a page and try the code I gave?
Try this and see if it works
$ret_obj = $facebook->api('/me/vanlelu:cook?food=http://fabubu.com/MKK/exam/cookie1.php', 'post',array('para'=>123456));

Comments Box Plugin: FQL query on comment table by xid returns an empty array

I expect this FQL query to return a non-empty array, because there are comments for that xid (see here). In the app itself, I use Javascript to perform the FQL query inside of window.fbAsyncInit and after FB.init({ //options }); like this:
var query = FB.Data.query("SELECT xid FROM comment WHERE app_id = " + facebookAppId + " and xid = '" + $this.attr("xid") + "'");
query.wait(function(rows) {
// do things
});
Unfortunately this also returns an empty array ([]). This is bad because we need to use the comments count to decide whether to use the xid attribute (for comment boxes which already have comments) or the href attribute (for comment boxes which don't yet have comments). This will allow us to not lose comments that were made while we used the old-style xid attribute.
Any ideas?
Probably you figured this out by now - I had the exactly same problem and solved it finally. In fact I found that you actually must not include the app_id. The key seems to be to get the correct access token (see my post).
hope it helps.

query Canvas URL using FQL

It seems like http://developers.facebook.com/docs/reference/fql/application/ provides all the information except for Canvas URL. Is it possible to query this information any other way?
Well, the solution I came up with, was simply calling the old admin.getAppProperties method.
$info = $facebook->api(array(
'method' => 'admin.getAppProperties',
'properties' => array('publish_url'),
));