iOS Facebook read and publish likes - ios

I have seen this documentation, but it asks for object-id to get number of like, it seems pretty simple but I am wondering for some time, how to get/know object-id of my object/thing?
Edit:
I am using this code:
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:#"/{object-id}/likes"
parameters:params
HTTPMethod:#"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];
What is {object-id} here ?

Finally I got my object-id in Object browser, I was able to create object there, object id was also present there.

Related

Facebook SDK on iOS Graph How to return video list

I have a graph request like:
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:#"/me/albums"
parameters:#{#"fields": #"id, name, picture, count"}
HTTPMethod:#"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
with these permissions:
self.but_FacebookConnect.readPermissions = #[#"public_profile", #"email", #"user_photos", #"user_videos"];
All my albums are there except for videos.
If I do a request on Facebook Graph API tool with /me/videos it also gives me a empty data[].
I tried with another account that has lots of videos... and this request /{user-id}/videos returned just one video.
Does anyone know if I'm missing something here?
the endpoint to receive the video list was /me/videos/uploaded

Fetch All Uploaded Images From Facebook in Ios?

I have use Facebook SDK for fetch photos but they provide us picture (for Profile Picture),cover(Cover Photo) but not provide me all photos of user. any one suggest me how to fetch all images from facebook.
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:#"/{facebook id}/albums"
parameters:nil
HTTPMethod:#"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
// Insert your code here
}];
I use above code for get images but its returns no data.
any one have idea about this then please tell me. thanks in advance.

iOS :Unable to get Facebook profile public data as media (Images & video)

I integrated FB account in my iOS mobile Application and it's approved by FB, But when any user logged in with FB login then only basic details coming successfully but unable to get the logged in User's media (Images/Video which uploaded by him as public)
I already mentioned the permission
"let facebookReadPermissions = ["public_profile","email","user_birthday","user_photos","user_videos"]"
Also i logged out from mobile safari and did fresh login but no luck.
After long search i am not able to fix this issue, Please help me.
You can try the Facebook Graph API. Check the code given below....
// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:#"/me/feed"
parameters:params
HTTPMethod:#"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];
If you are taking the permission in FB login than for getting the data you should use this code after successful login to FB.
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:#"/me"
parameters:#{ #"fields": #"id,name,photos,videos,email,picture,birthday",}
HTTPMethod:#"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
// Insert your code here
}];

iOS can't send dictionary parameters in FBSDKGraphRequest

I am trying to get the profile picture of a Facebook user in a reasonable quality from my app. By default, without any parameters, the request to the path "me?fields=picture" fetch the small one but using a parameters dictionary with the key #"type" and value #"large" would retrieve the large one. However, the api seems to be ignoring the parameters.
FBSDKGraphRequest* picRequest = [[FBSDKGraphRequest alloc] initWithGraphPath:#"me?fields=picture" parameters:[NSDictionary dictionaryWithObject:#"small" forKey:#"type"] HTTPMethod:#"GET"];
[picRequest startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (result) {
NSString* profilePictureURLString = [[[(NSDictionary*) result objectForKey:#"picture"] objectForKey:#"data"] objectForKey:#"url"];
NSURL* profilePictureURL = [NSURL URLWithString:profilePictureURLString];
NSData* profilePictureData = [NSData dataWithContentsOfURL:profilePictureURL];
}];
The resulting data is always the small picture with 50x50 pixels.
Can somebody help me please? Thanks!
You can set the size of the picture like picture.width(float).height(float). See the example below:
FBSDKGraphRequest* picRequest = [[FBSDKGraphRequest alloc] initWithGraphPath:#"me?fields=picture.width(200).height(200)"
parameters:nil
HTTPMethod:#"GET"];
You can test the request into Graph API Explorer

Facebook SDK v4 + Parse 1.7.5 issue

I've updated my SDKs from Facebook and Parse to the newest ones which includes some change in the PFFacebookUtils structure.
I would like to create a PFUser with some content from FB. It have been working for a long time before the update, but now when I log in, I only receive the user's name and FBID as result from the Facebook request.
This is how "I" log in:
NSArray *permissionsArray = #[#"public_profile", #"email", #"user_education_history", #"user_work_history", #"user_birthday", #"user_friends", #"user_photos"];
[PFFacebookUtils logInInBackgroundWithReadPermissions:permissionsArray block:^(PFUser *user, NSError *error) { ... }];
This is how I try to get the results:
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:#"me" parameters:nil];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
NSLog(#"Result %#", result);
...
}];
The log only shows this:
2015-08-03 01:41:15.039 XXXXXX[10807:2640469] Result {
id = 1015XXXXXXXXXXXX;
name = "Simon XXXX";
}
The Facebook App ID is set in the pList.
The latest Facebook SDK uses the Graph API v2.4, so the special me request needs the specific fields as query parameters to the graph path.
So, if you need to access the first, last name and email, the graph path in your code would look something like this:
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:#"me?fields=first_name,last_name,email" parameters:nil];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
NSLog(#"Result %#", result);
...
}];
I also suggest that you check out and play with the Graph API Explorer (note the API version dropdown in the top right corner).

Resources