I'm getting photo likes with this request, but I want to add the summary which returns to me the total likes count:
NSString *path=[NSString stringWithFormat:#"/%#/likes",IdPhoto];
[FBRequestConnection startWithGraphPath:path
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
{
}];
How can I add it?
Try with this call:
"/%#/likes?summary=true"
Source: https://developers.facebook.com/docs/graph-api/reference/v2.3/object/likes#read
Related
I want to fetch Facebook logged in user's interests and likes, which I'm able to do.
But I'm not getting the image for pages liked by user or image for user interests.
The following code lets me fetch user likes:
[FBRequestConnection startWithGraphPath:#"/me/likes"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
NSLog(#"User interests data: %#",result);
}];
which returns the following json data:
data = (
{
category = "Musician/band";
"created_time" = "2014-08-08T05:09:56+0000";
id = 9770929278;
name = Adele;
},
{
category = "Musician/band";
"created_time" = "2014-08-08T05:02:09+0000";
id = 5027904559;
name = Shakira;
}
);
but, I want images for the pages liked. How can I do that?
Any help would be appreciated.
Thanks in advance.
You can execute 1 more Graph API call for each for the likes:
[FBRequestConnection startWithGraphPath:#"/me/likes"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
NSArray *data = [result objectForKey:#"data"];
for(NSDictionary *liked in data) {
NSString *page_id = [liked objectForKey:#"id"];
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:#"/%#/picture", page_id] parameters:nil HTTPMethod:#"GET" completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
// Get your profile pic here
}
}];
}
}];
It will return the public details of Page. See documentation for more information.
I am using Facebook graph api in my app. I want to get user's posted videos. When I login I get basic info. But when i query about posts i only get id in result.
My code is:
-(void)getPosts {
NSMutableDictionary *par = [[NSMutableDictionary alloc]init];
[par setObject:#"posts" forKey:#"fields"];
[FBRequestConnection startWithGraphPath:#"me"
parameters:par
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
)
{
//handle the result
if(!error)
{
NSLog(#"%#",result);
}
else
{
NSLog(#"%#",[error localizedDescription]);
}
}];
}
Please help if I am doing wrong or missing something. Thanks in advance
with the referance from facebook dev API
https://developers.facebook.com/docs/graph-api/reference/v2.0/user/videos
you got Logged in User Video using this method:
/* make the API call */
[FBRequestConnection startWithGraphPath:#"/me/videos"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
}];
it's Filed object is
You need to set first Permission of user_videos as par doc said:
A user access token with user_videos permission is required to see all videos that person is tagged in or has uploaded.
HERE IT IS SAMPLE CODE:
http://www.filedropper.com/fblogin
1) Here is a basic logic to get User's uploaded video...(shows all videos that were published to Facebook by user)
/* make the API call */
[FBRequestConnection startWithGraphPath:#"me/videos/uploaded"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
arrFbUserUploadVideos= [result objectForKey:#"data"]; //get all data in NSMutableArray
}];
Note: This will give the video Uploaded by the user..
2) and if you also want video list in which User tag (shows all videos use person is tagged in) in that case
/* make the API call */
[FBRequestConnection startWithGraphPath:#"me/videos"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
arrFbUserTagVideos= [result objectForKey:#"data"]; //get all data in NSMutableArray
}];
Note: This will give the video in which user is tag..
HERE IS A REFERENCE LINK:
How can i get the cover of a profile with the FacebookSDK in iOS?
[FBRequestConnection startWithGraphPath:#"/me/events?fields=cover"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
NSLog(#"%#", result);
}];
you can also get facebook cover pic by simply calling
http://graph.facebook.com/{user_id or page_id}?fields=cover
a question about Facebook sdk for iOS.
If I have an active session how can I get only the user ID?
Is there a simple way to obtain this id without use this example code?
if (FBSession.activeSession.isOpen) {
[[FBRequest requestForMe] startWithCompletionHandler:
^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *aUser, NSError *error) {
if (!error) {
// I can take the user id..
}
}];
}
+ (NSString *)activeUserId {
return [FBSDKAccessToken currentAccessToken].userID;
}
if you are already logged in on facebook.
This is best way to take user id, instead of directly access using dot.
[[FBRequest requestForMe] startWithCompletionHandler:
^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *aUser, NSError *error) {
if (!error) {
NSLog(#"User id %#",[aUser objectForKey:#"id"]);
}
}];
[FBRequestConnection startWithGraphPath:#"/me"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
NSDictionary *result,
NSError *error
) {
/* handle the result */
_fbId = [result objectForKey:#"id"];
}];
i am using the ios sdk 3.0 to post simple text to user facebook wall , below is the code is use to post to facebook
[FBRequestConnection
startForPostStatusUpdate:text completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
{
if (!error)
{
NSLog(#"the status posted");
}
}];
but i get the error from facebook like
FBSDKLog: Response <#1115> :
The operation couldn’t be completed. (com.facebook.sdk error 5.) . any help would be appreciated.
The bug is if you try to share an NSString.
This works:
[FBRequestConnection startForPostStatusUpdate:#"test"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
}];
This gives you the error:
NSString *testString = #"test";
[FBRequestConnection startForPostStatusUpdate:testString
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
}];