OpenGraph是一种协议,用于在社交网络中创建和分享开放图形(如Facebook Graph)。在FB.api中指定过滤器的步骤如下:
access_token
:Facebook SDK
,并根据提示获取app_id
和app_secret
。Facebook SDK
中启用Graph API
,并获取access_token
。access_token
获取user_id
和graph_url
:access_token
调用GET
请求,在me
资源中获取user_id
:GET /v2.11/me?access_token=<access_token>{
"id": "{user_id}",
"first_name": "John",
"last_name": "Doe",
"birthday": "01-01-1990",
"gender": "male",
"email": "john.doe@example.com",
"locale": "en_US"
}{user_id}
:{user_id}
user_id
和graph_url
获取user_info
和friend_list
:user_id
调用GET
请求,在me/friends
资源中获取friend_list
:GET /v2.11/{user_id}/friends?access_token=<access_token>{
"data": [
{
"id": "{user_id}",
"first_name": "John",
"last_name": "Doe",
"birthday": "01-01-1990",
"gender": "male",
"email": "john.doe@example.com",
"locale": "en_US"
},
...
]
}friend_list
:friend_list
获取user_info
:friend_list
调用GET
请求,在me/friends/{friend_id}
资源中获取user_info
:GET /v2.11/{user_id}/friends/{friend_id}?access_token=<access_token>{
"id": "{user_id}",
"first_name": "John",
"last_name": "Doe",
"birthday": "01-01-1990",
"gender": "male",
"email": "john.doe@example.com",
"locale": "en_US"
}user_info
:user_info
创建一个OpenGraph
对象:OpenGraph
对象,其中包含user_info
中的所有属性:{
"id": "{user_id}",
"first_name": "John",
"last_name": "Doe",
"birthday": "01-01-1990",
"gender": "male",
"email": "john.doe@example.com",
"locale": "en_US",
"friend_list": [
{
"id": "{user_id}",
"first_name": "John",
"last_name": "Doe",
"birthday": "01-01-1990",
"gender": "male",
"email": "john.doe@example.com",
"locale": "en_US"
},
...
]
}OpenGraph
对象添加到friend_list
:OpenGraph
对象添加到friend_list
:{
"data": [
{
"id": "{user_id}",
"first_name": "John",
"last_name": "Doe",
"birthday没有搜到相关的沙龙
领取专属 10元无门槛券
手把手带您无忧上云