Determining number of comments of facebook status - api

How do I determine number of comments on a facebook status?
I thought of doing it through "stream" table. But I do not know how to query only status updates and not other posts through "stream" table.
I can't find a way to know "post_id" of "stream" table from "status_id" of "status" table.

Go to me/feed in the graph API. In the feed (stream) item, there is a comments object. In that comments object there will be a max of 2 comments shown, however, there is a comment count property that will tell you the total number of comments for that stream item.

Related

SQL model follows to retrieve previous notifications

These are my tables:
Author
author_id text
Client
client_id text
Post
author_id text
post_id text
Follow
client_id text
author_id text
I am having trouble modeling the follow table to achieve the following:
1)Client can fetch all the posts from authors which he is currently following
2)Client can follow then unfollow then follow and so on...
3)Whenever an author adds a post, clients receive a notification for the post(this is done through another service(firebase) which doesn't provide a way to fetch previous notifications)
4)Client can fetch all previous notifications he received(i'm having trouble with this point)
Does anybody have an idea how to model my tables to be able to query for the last point.
Thank you
If you want to be able to track the history of a client following an author, rather than just the current state, then you need effective start and end dates on your Follow table.
This will also allow you to track theoretical notifications (i.e. when a notification should have gone out). If you want to track actual notifications then you would need your notification process to record successful notifications in a table.
Your Post table also need a date column

Does surveymonkey api return the unique ID associated with their unique id specifications?

Can anyone tell me if they are know for certain whether or not survey monkey's api has the ability to return the unique ID associated with their designated unique id specifications:
http://help.surveymonkey.com/articles/en_US/kb/Can-I-track-respondents-using-a-unique-ID
It states the following regarding viewing this in the aforementioned link:
When these results come back on the survey, that custom ID of "00001"
appears in the Custom Value field in the Analyze > Browse Responses
section.
However I cannot find any mention of this data being returned from their API in the API documentation:
https://developer.surveymonkey.com
It can be retrieved by sending 'custom_id' as a requested field to 'get_respondent_list':
https://developer.surveymonkey.com/mashery/get_respondent_list
It will then be in the 'custom_id' field in the respondent's dictionary.

Likes on comment replies with Graph API

I'm trying to get the number of likes for each comment reply from the graph API.
Given this JSON-reply from a thread http://graph.facebook.com/10150790362005844_23680728, I can't seem to find the correct id to use in order to get number of likes on each comment.
E.g. https://graph.facebook.com/10150791016840844 returns false.
I did some experimenting with the facebook-comments, and found out that the correct id should be *grap-link*10150790374830844_23680907, but I can't find a way to locate this id through regular means in the Graph API...
This is an interesting one. This ID is the id for a comment. You can see this by looking at the type field here: http://graph.facebook.com/10150790362005844_23680728?metadata=1
To get the like counts for the comment replies, you're going to have to drill UP to find the post_id that this comment was originally attached to, then query for /POST_ID/comments, which will give you the like count.
If you can't find the comment otherwise, You're going to have to page through /user/feed until you find the post showing this comment was created and get the post_id from there.

Selecting specific joined record from findAll() with a hasMany() include

(I tried posting this to the CFWheels Google Group (twice), but for some reason my message never appears. Is that list moderated?)
Here's my problem: I'm working on a social networking app in CF on Wheels, not too dissimilar from the one we're all familiar with in Chris Peters's awesome tutorials. In mine, though, I'm required to display the most recent status message in the user directory. I've got a User model with hasMany("statuses") and a Status model with belongsTo("user"). So here's the code I started with:
users = model("user").findAll(include="userprofile, statuses");
This of course returns one record for every status message in the statuses table. Massive overkill. So next I try:
users = model("user").findAll(include="userprofile, statuses", group="users.id");
Getting closer, but now we're getting the first status record for each user (the lowest status.id), when I want to select for the most recent status. I think in straight SQL I would use a subquery to reorder the statuses first, but that's not available to me in the Wheels ORM. So is there another clean way to achieve this, or will I have to drag a huge query result or object the statuses into my CFML and then filter them out while I loop?
You can grab the most recent status using a calculated property:
// models/User.cfc
function init() {
property(
name="mostRecentStatusMessage",
sql="SELECT message FROM statuses WHERE userid = users.id ORDER BY createdat DESC LIMIT 1,1"
);
}
Of course, the syntax of the SELECT statement will depend on your RDBMS, but that should get you started.
The downside is that you'll need to create a calculated property for each column that you need available in your query.
The other option is to create a method in your model and write custom SQL in <cfquery> tags. That way is perfectly valid as well.
I don't know your exact DB schema, but shouldn't your findAll() look more like something such as this:
statuses = model("status").findAll(include="userprofile(user)", where="userid = users.id");
That should get all statuses from a specific user...or is it that you need it for all users? I'm finding your question a little tricky to work out. What is it you're exactly trying to get returned?

A way to query both news feed and wall using a single request

I'm trying to find the best way to query both news feed and wall using a single request.
First attempt:
Query me/home and me/feed in batch request.
Problem: querying me/home gives me bad results due to Graph API bugs (showing blocked items and on the contrary not showing some items that should be shown) so I decided to change to FQL which seems to handle it much better.
Second attempt:
Use single batch request to query:
(1) me/feed directly.
(2) fql.query for stream table with filter_key set to 'others'.
Problem: Needs to also query for user names because the stream table contains only ids.
Third attempt:
Use batch request to query:
(1) me/feed directly
(2) fql.multiquery for stream table with filter_key set to 'others' and the names table with "WHERE id IN (SELECT actor_id FROM #stream)".
Problem: Fails. It returns "Error: batch parameter must be a JSON array" although it is a json array.
Fourth Attempt:
Use fql.multiquery to get news feed stream, wall stream and names.
Problem: I have no idea how to get a view similar to me/feed using FQL. The best I could get is a list of all my own posts but it doesn't show photos the user is tagged in (so I guess more things are missing).
Appreciate any hints.
Due to FQL not doing SQL style joins, getting information from multiple tables in one query is currently impossible.
Use FQL on the stream table to get the list of posts you want to display be sure to grab the source_id. The source_id can be a user id, page id, event id, group id, and there may be more objects too, just don't remember off the top of my head. (You may also want to do similar caching of the actor_id, target_id and viewer_id)
Cache the source_ids in a dictionary style data cache with source_id being the PK.
Loop thru the cache for ones you don't have information on
Try grabbing the information from the user table based upon id, then next the page table, then event table, and group table until you can find what that ID belongs to. Store the information in your cache
For display merge together the stream table items with the source_id information.