Get Facebook user's page likes iOS - ios

I am making an iOS application where I want to get the list of all the pages that has been liked by the Facebook user. I have already used the permission 'user_likes' using Facebook Graph API. Now I want to display it.
Refer this: https://developers.facebook.com/docs/graph-api/reference/v2.2/object/likes
Kindly help.

I got my answer and this is how I made it happen:
//Page likes
/* make the API call */
[FBRequestConnection startWithGraphPath:#"me/likes?limit=10" parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
NSLog(#"Likes are:\n\n%#",result);
}];
NSString *fbCountry=[

Related

Facebook Like Button - canĀ“t build archive with the new feature FBLikeControl

I want to integrate Facebook like Button with the new feature FBLikeControl. On the facebook page they have written it is only for developement and not for publication on the AppStore.
Here is the Tutorial from facebook https://developers.facebook.com/docs/ios/like-button/
When I want to build an archive with my code I get the error message "Use of undeclared identifier FBBetaFeaturesLikeButton".
Is there a way to solve this problem or if there's any other alternative solution, I would appreciate that.
Here is my code:
[FBSettings enableBetaFeature:FBBetaFeaturesLikeButton];
[FBSettings enablePlatformCompatibility:NO];
FBLikeControl *like = [[FBLikeControl alloc] init];
like.frame = CGRectMake((self.frame.size.width-like.frame.size.width)/2, facebookY, 60, 20);
like.objectID = #"https://www.facebook.com/pages/abcdefgh/123456789?ref=tn_tnmn";
[self addSubview: like];
This link says:
FBLikeControl is a preview feature and may not be deployed to the App
Store. Only developers and testers of your Facebook app will be able
to use the Like Button.
is the reason you are unable to built the archive.
There are several ways to implement like, the one which worked for me is as follows:
[FBRequestConnection startWithGraphPath:#"/object-id_to_like/likes"
parameters:nil
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
// Handle error here
}];
Here is the Link
EDIT: It is pretty simple, you just have to replace FBLikeControl code in your project with the above method call replacing object-id_to_like to the actual post-id/ object-id. What the method does is it POSTS a like on corresponding object/post.
In case you have problem to fetch the object id of the object/post you can fetch it using same method with the HTTPMethod parameter set to #"GET". Following code will return posts from your timeline:
[FBRequestConnection startWithGraphPath:#"/me/home"// you can change this to #"/me/feed" if required
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error ) {
if (!error){
// Fetch Post-id/Object-id here
}else{
// handle error here
}
}];

facebook Like and comment not working in ios

I am working on Facebook like and comment in ios,i am getting the response i.e id of a like object.But it is not showing in Facebook.I am using this code to like a object.
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
#"http://samples.ogp.me/226075010839791", #"object",
nil
];
/* make the API call */
[FBRequestConnection startWithGraphPath:#"/me/og.likes"
parameters:params
HTTPMethod:#"POST"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
}];
I am getting one more problem i.e if i clicked on another object of a same user it is giving an error.
message = "(#3501) User is already associated to the object type, website, on a unique action type Like. Original Action ID: 654561277932515";
Please help me.

How to Like in Facebook using FacebookSDK.framework Facebook

I have used FacebookSDK.framework for Facebook integration in my application. I have to like one facebook page from application. I have used following code for liking page.
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:#"https://www.facebook.com/demoappname"
, #"object",
nil
];
/* make the API call */
[FBRequestConnection startWithGraphPath:#"me/og.likes"
parameters:params
HTTPMethod:#"POST"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
)
{
NSDictionary *currentResult= [(NSArray *)[result data] objectAtIndex:0];
if(!error)
{
NSLog(#"there is no error");
}
else
{
NSLog(#"There is something wrong at here.");
}
}];
But I am not clear what I have to pass in "object" parameter. Can anybody help to what I am doing wrong at here.
Thanks,
If you read this documentation, it says-
The og.likes action can refer to any open graph object or URL, except for Facebook Pages or Photos.
So, liking a page with Graph API isn't possible.
The only thing you can do- add a Like Button to the page in your app.

How to post comment reply on a specific post in iOS programmatically?

I am new to iOS programming and I just want to know that how can we reply on a specific post?
I have read a lot of links but I can't get the point.
http://developers.facebook.com/docs/graph-api/reference/object/comments
I have use this method but it is not working properly this code update/edit your post or comment:
-(void) abc
{
[FBRequestConnection startWithGraphPath:#"/YOUR_POST_ID/comments"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
NSLog(#"Results == %#",result);
NSLog(#"error == %#",error);
}];
}
and plus I am calling this method into my textfield
[myReplyingUITextField addTarget:self action:#selector(abc) forControlEvents:(UIControlEventEditingDidEndOnExit)];
You need to add the message parameter to your API call. Pass the comment into this parameter and you'll be able to comment on the post. See the API documentation.

How to get checkin data from facebook account and friends/others data

I am using facebook-ios-sdk-3.11.1 and Xcode 5 and i need to support ios 5,6,7
Old Facebook Doc for checkin
New Facebook Doc for checkin
From this info i have found following code needs to be implemented
[FBRequestConnection startWithGraphPath:#"/me/checkins"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
NSLog(#"result %#",result);
}];
Outuput:
result {
data = (
);
}
I am getting no results even though i have checkin to one place from my facebook account
And how can we get data of friends checkin of user's friends as well

Resources