Getting all commets for an event with FQL - facebook-graph-api

i am trying to list all comments for an event created by a certain page. I am getting the EID for for the event with a multiquery like this:
{ 'eids':'
SELECT eid, uid
FROM event_member
WHERE uid = 64565465464
'events':'
SELECT eid, name, venue, location, start_time, creator
FROM event WHERE eid
IN (SELECT eid FROM #eids)
AND creator = 64565465464 ORDER BY start_time ASC'}
I am totally clueless how to get the comments for that event with that EID.
Does anyone know how?

You will use the stream FQL table. The source_id on this table relates to the eid of the event table.
Example query via your above multi-query:
SELECT message FROM stream WHERE source_id IN (SELECT eid FROM #eids)
Docs: https://developers.facebook.com/docs/reference/fql/stream

Related

How to display and update the records I have added/insert in the Apex interactive report

I've created an interactive report to add/update/delete employee info records in custom db table.
My end user requirement is upon entering the employee number in the EMPNO field, all the details from the oracle standard table such as employee name, marital status, gender, bday must be auto generated in the form and they will only manually input the location name and mode of exit.
Now I created 3 pages: 1.home page, 2.add page, 3.update page
On page 1 (home page)
I have here the select SQL
with checkbox
On page 2 (add page),
In the page processing portion
I have
EventAddRecord
Source: db , plsql code
Here's my sample code:
BEGIN
INSERT INTO EMPINFOTBL
(PERSON_ID,
EMPLOYEE_NUM,
EMPLOYEE_NAME,
MARITAL_STATUS,
BDATE,
GENDER,
LOCATION_NAME,
MODE_OF_EXIT
)
VALUES
(SELECT PERSON_ID FROM
PER_PEOPLE_X WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
(SELECT EMPLOYEE_NUMBER ID FROM
PER_PEOPLE_X WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
(SELECT FULL_NAME FROM
PER_PEOPLE WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
(SELECT MARITAL_STATUS FROM
PER_PEOPLE WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
(SELECT DATE_OF_BIRTH FROM
PER_PEOPLE WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
(SELECT GENDER FROM
PER_PEOPLE WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
:P2_LOCATION_NAME,
:P2_MODE_OF_EXIT
);
END;
Buttons
SAVE with dynamic action
When click add button if True submit page
Now my problem is how to do the update when I click the check box,
I want my record to be displayed in the form because currently when I click the check box the form is null
To create a new record (using Page 2), you'd create a select list item which is based on per_people table; you'd display any information you want, but you'd return employee ID:
select full_name as display_value,
employee_num as return value
from per_people
order by full_name;
After selecting desired person, enter values into P2_LOCATION_NAME and P2_MODE_OF_EXIT items. When you hit the "Save" button (which submits the page), run the process (I modified what you wrote; should be way simpler):
INSERT INTO empinfotbl (person_id,
employee_num,
employee_name,
marital_status,
bdate,
gender,
location_name,
mode_of_exit)
SELECT person_id,
employee_number,
full_name,
marital_status,
date_of_birth,
gender,
:P2_LOCATION_NAME,
:P2_MODE_OF_EXIT
FROM per_people
WHERE employee_num = :P2_EMPLOYEE_NUM;
As of updating existing values: I'd again suggest you to use the Wizard as it creates everything you need - form page is based on empinfotbl table, while "Edit" button in Interactive report sends the ID value to form page whose pre-rendering process fetches data related to employee identified by passed ID.
If you created your own page, you'll have to do it all yourself.
You said:
I want my record to be displayed in the form because currently when I click the check box the form is null
Form items are empty because Apex didn't know what to fetch. As I said: pass ID value, create pre-rendering process. Or start over with the Wizard (I prefer that option).
#Littlefoot has given a perfect answer already, here are just some extra steps that might guide you to a solution (it's the "or start over with the wizzard" piece from Littlefoot's answer). I'd suggest looking how apex generates its pages when you do it out of the box. Just for testing, follow these steps
Create a new page of type "Interactive Report" and make sure to check the "Include Form Page" attribute
Give the form page a name and select "PER_PEOPLE" as table/view name
In the 2nd page of the dialog, select the primary key column of PER_PEOPLE: person_id
Click "Create Page"
You now have a working form and report that you can further customize to your specific requirements. It should give you a good idea of how a form and a report is generally configured in APEX and it saves you a ton of time
Notices how in the report page:
The edit link has the form page as target and passes the id
The CREATE button has the form page as target without the id
In the form page
No custom code is needed to initialize the form data for the current record. Instead the native process of type "Form - Initialization" is used.
No dynamic actions are used to perform the inserts - for a form that is a bad practice. Avoid it.
No custom code is needed to perform the inserts or update. Instead the native process of type "Form - Automatic Row Processing" is used.
Study these pages and apply similar logic to your own pages. It'll be a better app.

Get all friends' ids who liked a post

I am using Facebook FQL to query stream table. I want to get the list of all user ids of friends who liked one of my post. Here is my query:
select post_id,likes.friends, likes.count from stream where source_id = me() and likes.count > 0 limit 200"
However, I only get maximum 4 friend ids in return, even if likes.count > 4, which is exactly like likes.sample.
Is this a bug, or a limitation of FQL? If I can't get full list of Likers here, which table I should look at? If this is not feasible with FQL, how can I make a similar query in Graph API?
Thank you.
Use a multi-query on the stream and like tables
{"posts": "select post_id, likes.count from stream where source_id = me() and likes.count > 0 limit 200",
"friends_who_like_posts":"select user_id FROM like WHERE post_id IN (SELECT post_id FROM #posts) AND user_id IN (SELECT uid2 FROM friend WHERE uid1 = me() )"
}

Appending Access Token to FQL Query

Is there a way to append my long term access token to the query given at Getting Facebook Events using fql ? The query at that link is
fql?q={"event_info":"SELECT name,description, pic_small,pic_big, eid,venue,location from event WHERE eid in (SELECT eid FROM event_member WHERE uid = me())", "event_venue":"SELECT name, username, page_id, location FROM page WHERE page_id IN (SELECT venue.id FROM #event_info)"}
Thanks in advance for any assistance...
UPDATE - The answer provided worked like a charm. THANK YOU!
Yes. Try this:
/fql?q=QUERY&access_token=TOKEN

FQL: Trouble joining tables where id is in format USERID_LINKID

I am running the following FQL via the php sdk:
{
"posts" : "SELECT post_id, actor_id, message, type FROM stream WHERE type = '80' AND message != '' AND filter_key in (SELECT filter_key FROM stream_filter WHERE uid='588853265' AND type='newsfeed') AND is_hidden = 0 ORDER BY created_time DESC LIMIT 50",
"actors" : "SELECT uid,name FROM user WHERE uid IN (SELECT actor_id FROM #posts)",
"links" : "SELECT owner, url FROM link WHERE link_id IN (SELECT post_id FROM #posts)"
}
I get results as expected for posts and for actors but not for links (results are empty). I believe the problem is that the link table uses a normal ID but my 'posts' from 'stream' show the ID in the format: USERID_LINKID.
I have played around with substr() and strlen() to get it to work with no luck.
There doesn't seem to be a way to get a link_id from a stream post. Your query is getting the id of the post, but not the link.
However, I don't think you need it. Get rid of the #links sub-query and add attachment to the SELECT statement in your #posts sub-query. You can get the link url at attachment->media->url.
One other critique: You might want to add additional sub-queries for #actors. The actor_id returned by the stream table can be a user, page, or group. Your FQL only resolves users. You'll end up with unknown IDs for links posted by groups and pages.

How to write FQL to fetch news feeds

I have to fetch all data which is on News Feeds (public wall). What query should I write ?
I wrote "SELECT likes,message FROM stream WHERE source_id = %lld limit 50 " query but it is returning my wall value. I want to fetch all data which is on my wall as well as on public (News Feed).
Thanks in advance
You need to use the filter_key to select the type of feed to use. The type you are after would probably be newsfeed, so the query could be something like this:
SELECT post_id, actor_id, target_id, message FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid = me() AND type = 'newsfeed')
For more information, have a look at the stream_filter docs.
How about doing it without querying FQL? :)
Use the Graph API instead:
https://graph.facebook.com/me/home?access_token=...
Try it on using "Graph API Explorer". /me/home