From bab57f6c99cb6f2369a07670d87596d57d8cca3d Mon Sep 17 00:00:00 2001 From: Diego Rauda Date: Mon, 27 Nov 2017 18:45:24 -0600 Subject: [PATCH 1/2] Expand the documentation for get_connection The field expansion feature of GraphAPI can be efficiently used through the 'fields' parameter of the get_connections method. This means that the user can obtain info from both the referenced edge in 'connection_name', and the node that is connected to 'object_id' through said edge. Doing so is very useful, as it can reduce the amount of calls to the API, and help the user access richer data through a simpler query. This information is not intuitively acquired from either the Facebook SDK for Python docs, or the GraphAPI reference guide. --- docs/api.rst | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 01eab8b2..95a5bb2f 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -171,6 +171,11 @@ Returns all connections for a given object as a ``dict``. between objects, e.g., feed, friends, groups, likes, posts. If left empty, ``get_connections`` will simply return the authenticated user's basic information. +* ``fields`` – A ``string`` or group of (comma separated) ``strings``. Accepts one + or more fields of the edge specified in connection_name, or one or more + fields/edges of the node connected to the given object_id by said edge. + This parameter allows for nested queries to the GraphAPI, supported by the + field expansion feature. See the GraphAPI docs for syntax and further examples. **Examples** @@ -180,8 +185,11 @@ Returns all connections for a given object as a ``dict``. friends = graph.get_connections(id='me', connection_name='friends') # Get the comments from a post. - comments = graph.get_connections(id='post_id', connection_name='comments') - + comments = graph.get_connections(id='post_id', connection_name='comments')} + + # Get the photos from a user, requesting info available from node "Photo". + # Note that only the edge "Page Photos" ("photos") is referenced. + photos = graph.get_connections(id='me', 'photos', fields='created_time','likes.summary(total_count)') get_all_connections ^^^^^^^^^^^^^^^^^^^ From 9f06b3bad38f1e20539140165cab5a17fa4a7a39 Mon Sep 17 00:00:00 2001 From: Diego Rauda Date: Mon, 7 Jan 2019 03:58:18 -0500 Subject: [PATCH 2/2] Update api.rst --- docs/api.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 95a5bb2f..3375bb0a 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -172,10 +172,11 @@ Returns all connections for a given object as a ``dict``. ``get_connections`` will simply return the authenticated user's basic information. * ``fields`` – A ``string`` or group of (comma separated) ``strings``. Accepts one - or more fields of the edge specified in connection_name, or one or more - fields/edges of the node connected to the given object_id by said edge. - This parameter allows for nested queries to the GraphAPI, supported by the - field expansion feature. See the GraphAPI docs for syntax and further examples. + or more fields of the edge specified in connection_name, or one or more + fields/edges of the node connected to the given object_id by said edge. + This parameter allows for nested queries to the GraphAPI, supported by the + field expansion feature. See the GraphAPI docs for syntax and further examples at + https://developers.facebook.com/docs/graph-api/using-graph-api/ **Examples**