Selecting specific fields with facebook graph api - php

I'd like to fetch statuses from users facebook newsfeed via the graph API.
It seems to be pretty simple when I have the right access token, then I can fetch this data with http://graph.facebook.com/home... But I want to fetch only statuses; no links, photos, videos and so on..
On the documentation page, I've seen many possibilities to specify selected data, for example I can limit obtained count of posts. Is there any possibility to control which data will be particularly fetched and which not? For example like graph.facebook.com/home?type="status"..
I can classify it in my PHP script, but then I need to be able to fetch a few more posts, like when I click on the more button on facebook or twitter, etc..I see some pagination data in Facebook JSON(I hope it's JSON:)), but I am propably not capable to use it in right way..
Thanks for your help!!

The doc page http://developers.facebook.com/docs/api says:
The Graph API allows you to read properties and connections of the Facebook social graph. You can use the API to read specific fields, get pictures of any object, introspect an object for metadata and get real-time updates on any changes.
...and...
You can choose the fields (or connections) you want returned with the "fields" query parameter. For example, this URL will only return the id, name, and picture of Ben: https://graph.facebook.com/bgolub?fields=id,name,picture

Related

Get my posts on facebook manage page

I need get ME posts in one of my manage pages, with the new version of facebook sdk.
Example:
I'm manage on Page A, and add a post in my name Adexe Rivera, and in this page there are a lot of posts. So I want to filter only posts by Adexe Rivera.
I know for get posts on pages it's necesary /page/feed, but I need add the filter from user.
I tried with Graph Api Explorer, with this FQL:
SELECT source_id, actor_id, post_id, target_id, message FROM stream WHERE source_id = "PAGE_ID" AND actor_id = "MY_ID"
and get the information that I'm searching.
But I know that since v2.0 FQL not works for sdk, so that I need it's make the same like FQL works in this version of graph
I already tried what documentation said, but not get my posts.
A user access token is required to retrieve posts visible to that person.
Thanks in advance
Filtering is not possible, you can only use the existing endpoints and filter on your own after getting the entries. There are several different endpoints, make sure you are using the correct one. They are all documented very well: https://developers.facebook.com/docs/graph-api/reference/v2.4/page/feed
Also, an App Access Token should be enough to get access to the endpoints if it´s a public post on a non-restricted Page:
An access token is required to view publicly shared posts.
If you don´t know about Access Tokens, read those articles:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/
Finally, it is not possible to use FQL giving me the expected result, so getting the "from" field in the /PAGEID/feed endpoint, and filtering the results, I get what I wanted.
Thanks for your answers and for their penalties, I have spent several days trying to maximize the performance of the SDK facebook.
Cheers

How can I get all the facebook page by category or subscribe on adding them?

For example: https://graph.facebook.com/181017065298015
Page has category, but I can't get category by FQL query like
SELECT categories FROM page WHERE name= "..."
This query return empty set
In the graph API I can subscribe for update only one page... But I need subscribe on adding any page with certain category! I don't found this in API.
There is a way to get this information by using API?
In other case direct me pls on operational metod
UPD:
Search page by graph API not allowed by page category, it works only for "name" field
https://graph.facebook.com/search?q=Games&type=page&access_token=...
There's a missmatch between the Graph API and FQL concerning the Page information available. The Graph API uses category, which is the "old" field, and FQL uses the newer categories. I think there's no way around this, one could consider this as a "flaw" in Facebooks API design.
Concerning your other question on "subscribing" (you mean liking I guess) all pages of certain category: This is NOT possible.

How to count facebook likes into MySQL Database

I have this project I'm working on (php mysql), it contains blocks of movies that can be shared through facebook like. The thing is that I want to count the facebook likes into DATABASE (which is movies table and users favourite table).
Have you looked through the facebook developer docs? Using the javascript api you can use methods such as "edge.subscribe" to call a function when people click like. This would then allow you to make an ajax request. The first part of this document describes this scenario
https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

How to retrieve the category-specific fields from a facebook page using facebook graph api?

In facebook developers api page it says:
A Page in the Graph API.
The fields shown below are some of the common fields of Facebook Pages. Pages may also contain other (or additional) category-specific fields.
Does anyone know how to retrieve those additional category-specific fields???
I´ve been looking on Internet but not a clue :-(
The doc for the facebook 'page' table shows fields and lists what category of page they are available to:
https://developers.facebook.com/docs/reference/fql/page/
For example, the band pages have a 'band_members' field that no other page type has. You should also check out Facebook Graph API batch requests which you can use to query for something and use the result in a second request using JSONPath notation. Do a search on this page for JSONPath and you'll see it near the bottom under the 'Specifying dependencies between operations in the request' section:
https://developers.facebook.com/docs/reference/api/batch/
Hope that helps!
-Kyle

facebook iframe php api

i am starting on a php based facebook app.
the documentation at facebooks developer page is quite confusing.
i have chosen the iframe method for rendering the canvas page. i have made my app in php and is hosted on my server. now the app loads fine in apps.facebook.com canvas. but the thing is I am unable to make API calls work.
what i wanted to know is how to transform the xml/JSON data received from the api calls to valid user-readable data. i mean friends.get gives me a bunch of uids. now how to make them appear as valid user profile image thumbnails or links?
i am very new to this. so any help would be appreciated. i just need to know how to work with the facebook API.
I would suggest using FQL instead - building your FQL queries will help you understand much more what goes on in FB under the hood as well plus if you are good in SQL you can combine multiple queries to give you friends pics and their IDs from diff tables in one resultset...
Use the FB fqlquery function call and pass your required column names there - e.g. you can see your stream from the following table: http://wiki.developers.facebook.com/index.php/Stream_%28FQL%29 and you can issue queries according to the examples given here: http://wiki.developers.facebook.com/index.php/Fql.query
e.g. this gives me the newsfeed from stream table, for all my friends (only):
$logged_in_user = $facebook->get_loggedin_user();
select source_id, post_id, message, likes, created_time, updated_time from stream where source_id in (select uid from user where uid in (select uid2 from friend where uid1=' . $logged_in_user . ')) and filter_key=\'nf\' order by updated_time"
You can query the User FQL table for the picture URLs of your friends and display those URLs in image containers of the frontend lang of your choice: http://wiki.developers.facebook.com/index.php/User_(FQL)
Use the Console for testing your queries: http://developers.facebook.com/tools.php
And use the MultiQuery http://wiki.developers.facebook.com/index.php/Fql.multiquery later when you are more comfortable using FQL queries

Categories