MCPcopy Create free account
hub / github.com/EasyIME/PIME / facebook_request

Method facebook_request

python/python3/tornado/auth.py:1038–1098  ·  view source on GitHub ↗

Fetches the given relative API path, e.g., "/btaylor/picture" If the request is a POST, ``post_args`` should be provided. Query string arguments should be given as keyword arguments. An introduction to the Facebook Graph API can be found at http://developers.faceboo

(
        self,
        path: str,
        access_token: Optional[str] = None,
        post_args: Optional[Dict[str, Any]] = None,
        **args: Any
    )

Source from the content-addressed store, hash-verified

1036 return fieldmap
1037
1038 async def facebook_request(
1039 self,
1040 path: str,
1041 access_token: Optional[str] = None,
1042 post_args: Optional[Dict[str, Any]] = None,
1043 **args: Any
1044 ) -> Any:
1045 """Fetches the given relative API path, e.g., "/btaylor/picture"
1046
1047 If the request is a POST, ``post_args`` should be provided. Query
1048 string arguments should be given as keyword arguments.
1049
1050 An introduction to the Facebook Graph API can be found at
1051 http://developers.facebook.com/docs/api
1052
1053 Many methods require an OAuth access token which you can
1054 obtain through `~OAuth2Mixin.authorize_redirect` and
1055 `get_authenticated_user`. The user returned through that
1056 process includes an ``access_token`` attribute that can be
1057 used to make authenticated requests via this method.
1058
1059 Example usage:
1060
1061 .. testcode::
1062
1063 class MainHandler(tornado.web.RequestHandler,
1064 tornado.auth.FacebookGraphMixin):
1065 @tornado.web.authenticated
1066 async def get(self):
1067 new_entry = await self.facebook_request(
1068 "/me/feed",
1069 post_args={"message": "I am posting from my Tornado application!"},
1070 access_token=self.current_user["access_token"])
1071
1072 if not new_entry:
1073 # Call failed; perhaps missing permission?
1074 self.authorize_redirect()
1075 return
1076 self.finish("Posted a message!")
1077
1078 .. testoutput::
1079 :hide:
1080
1081 The given path is relative to ``self._FACEBOOK_BASE_URL``,
1082 by default "https://graph.facebook.com".
1083
1084 This method is a wrapper around `OAuth2Mixin.oauth2_request`;
1085 the only difference is that this method takes a relative path,
1086 while ``oauth2_request`` takes a complete url.
1087
1088 .. versionchanged:: 3.1
1089 Added the ability to override ``self._FACEBOOK_BASE_URL``.
1090
1091 .. versionchanged:: 6.0
1092
1093 The ``callback`` argument was removed. Use the returned awaitable object instead.
1094 """
1095 url = self._FACEBOOK_BASE_URL + path

Callers 1

Calls 1

oauth2_requestMethod · 0.80

Tested by

no test coverage detected