質問

When I'm getting a status/link/photo from facebook API, how do I know if it has been shared with the public or if it's a private post?

Also - is there a way to query only public posts?

I'm currently using the /<username>/status /<username>/links /<username>/photos endpoints.

役に立ちましたか?

解決

With the graph api

From the 3 endpoints you are using, only one gives you access to the privacy settings the /<username>/links. It returns a privacy object, something like this:

{
  "id": "USER_FB_ID", 
  "links": {
    "data": [
      {
        "id": "ID_OF_THE_POST", 
        "from": {
          "name": "Fábio Antunes", 
          "id": "USER_FB_ID"
        }, 
        "message": "Check this awesome link", 
        "privacy": {
          "description": "Friends; Except: Restricted", 
          "value": "ALL_FRIENDS", 
          "allow": "", 
          "deny": "", 
          "networks": "", 
          "friends": ""
        },
(etc....) 

With FQL

To solve your problem you could use FQL this way you can get the 3 endpoints that have public access.

For the links you can use this query:

Select link_id,owner_comment, title, url, privacy FROM link WHERE owner = me() AND privacy.value='EVERYONE'

note: check the link table to see if there are any fields that you may want to add to this query

Since the links table from the 3 endpoints is the only with privacy settings structure to get the user photos and statuses that are public you will have to use the privacy table.

To get all the users public photos I made 2 joins, first I'm getting the user photos, then I want the privacy settings of the photos that are available to everyone and then I select the photos that have the privacy settings public:

SELECT caption,src_big FROM photo WHERE object_id IN (SELECT id FROM privacy WHERE value='EVERYONE' AND object_id IN (SELECT object_id FROM photo WHERE owner=me()))

note: check the photo table to see if there are any fields that you may want to add to this query

To get the public statuses it's the same process for the photos, two joins:

SELECT status_id , message, place_id  FROM status WHERE status_id IN (SELECT id FROM privacy WHERE value='EVERYONE' AND object_id IN (SELECT status_id FROM status WHERE uid=me()))

note: check the status table to see if there are any fields that you may want to add to this query

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top