我已经使用FB凭据成功登录了我的应用程序,并且获得了访问令牌以及我的Facebook页面名称和权限。
func graphRequest() {
var Requset : FBSDKGraphRequest
let acessToken = String(format:"%@", FBSDKAccessToken.current().tokenString) as String
let parameters1 = ["access_token":FBSDKAccessToken.current().tokenString]
Requset = FBSDKGraphRequest(graphPath:"me/accounts", parameters:parameters1, httpMethod:"GET")
Requset.start(completionHandler: { (connection, result, error) -> Void in
if ((error) != nil)
{
print("Error: \(error)")
}
else
{
print(result!)
}
})
}
响应:
{
data = (
{
"access_token" = {MY_TOKEN};
category = Restaurant;
"category_list" = (
{
id = 273819889373419;
name = Restaurant;
}
);
id = 338236656688333;
name = "Restaurent TEST PAGE";
perms = (
ADMINISTER,
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
);
}
);
paging = {
cursors = {
after = MzM4MjM2NjU2Njc2MzMz;
before = MzM4MjM2NjU2Njc2MzMz;
};
};
}
我想在我的应用程序中显示我的 Restaurent TEST PAGE (喜欢的测试页)计数,如何在ios中获得它。我浏览了Facebook API,无法完全找到详细信息。
有人可以帮我显示目标C或Swift中的Facdebook页面点赞次数吗?
我已按以下要求提出请求。
func getPageLikes(){
let parameters1 = ["access_token":FBSDKAccessToken.current().tokenString]
let request: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "/338236656688333/likes", parameters: parameters1, httpMethod: "GET")
request.start { (connection, result, error) in
print("result: \(result!)")
}
}
响应为:
result: {
data = (
);
}
答案 0 :(得分:0)
使用以下代码获得喜欢的详细信息:
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/{object-id}/likes"
parameters:params
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];
有关更多信息: https://developers.facebook.com/docs/graph-api/reference/v3.1/object/likes