I am working on one app in that i want to set profile picture of Facebook.
I am not getting any solution to set picture using sdk so it will be fine to have solution using graph API.
if ([FBSDKAccessToken currentAccessToken]) {
[[[FBSDKGraphRequest alloc]initWithGraphPath:#"me" parameters:#{#"fields":#"picture"}] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
NSLog(#"%#",result);
}];
}
After getting result, use the nsurlsession and get data, pass into the imageview[use main thread when using uielement].
Related
For an iOS app, using facebook sdk i need to fetch photos from user's album but i need to fetch them in a single request so that i could get info about albums and containing photos at the same time, for that i tried
/me/albums?fields=count,name,photos.limit(10){images}
that api call is working fine in Graph api explorer but not on iOS platform. I only need images field of photos that is why using
above api call
If i run this api it runs fine
/me/albums?fields=count,name,photos.limit(10)
only {images} part is causing the problem, the error message which i get is of unsupported url, have acquired the permissions for user_photos
Code :
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:#"/me/albums?fields=count,name,photos.limit(10){images}" parameters:nil HTTPMethod:#"GET"];
FBSDKGraphRequestConnection *connection = [[FBSDKGraphRequestConnection alloc] init];
[connection addRequest:request completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if(!error) {
NSLog(#"result %#",result);
} else {
NSLog(#"error description : %#",error.description);
}
}];
[connection start];
I was making the final url call by adding/removing fields from graph api explorer side pane, the request call it was generating was
/me/albums?fields=count,name,photos.limit(10){images}
not working on iOS platform, but if i use this syntax instead
/me/albums?fields=count,name,photos.limit(10).fields(images)
to address fields of photos then it works fine, got the inspiration from answer posted here
I am writing facebook interaction code in swift language for iOS. I have converted login and other code but stuck with sharing methods.
I am not able to find requestWithGraphPath method of FBRequest class in swift. If somebody know about this then please help me here. I have searched for solution on web but fail to find.
This is my sharing code in Objective-C
FBRequest *req=[FBRequest requestWithGraphPath:#"me/feed" parameters:params HTTPMethod:#"POST"];
[req startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error{
if (!error) {
// Sucess! Include your code to handle the results here
NSLog(#"Successful sharing");
} else {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"Error while sharing data");
}
}];
Thank you in advance.
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
}
}];
I'm developing a small app with Xcode that logs into Facebook and retrieves user informations. This is the part of code that performs the request:
[[FBRequest requestForMe] startWithCompletionHandler:
^(FBRequestConnection *connection,
NSDictionary<FBGraphUser> *user,
NSError *error) {
if (!error) {
// at this point user variable contains all user's info I need
NSLog (#"%#", user.name);
} else {
NSLog(#"ERRORE");
}
}];
These infos are returned in English. How can I retrieve them in the same language of Facebook profile ? For example, since the language I choose for my Facebook profile is Italian, I need to retrieve all my infos in italian (with this code user[#"relationship_status"] returns "married", it should return "sposato")
Thanks to this post I found out (a possible) solution: run a FQL query with the locale parameter set to the desired language. In my case it should be locale=it_IT, as stated by this table
I am working for an iOS app and I want to integrate Facebook sdk 3.1 for posting status on facebook but I really dont have any idea how to do it. Can anybody please provide me link to easy tutorials or step by step approach for how to do it.
To set up your Xcode project, read the instructions on the Facebook developer site.
You can create / open a session using [FBSession openActiveSessionWithAllowLoginUI:YES];
To publish to your timeline, you'll need to authorise with write permissions:
[[FBSession activeSession] reauthorizeWithPublishPermissions:#[ #"publish_stream" ] defaultAudience:FBSessionDefaultAudienceEveryone completionHandler:^(FBSession *authSession, NSError *authError) {
// If auth was successful, create a status update FBRequest
if (!authError) {
FBRequest *postRequest = [FBRequest requestForPostStatusUpdate:#"Hello, world!"];
[postRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
// TODO: Check for success / failure here
}];
}
}];
Try this:
[FBRequestConnection startForPostStatusUpdate:#"I've been through the storm, future, present and past.. Light as a feather, swift as a cat.. Clickety clack, clickety clack!!" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSLog(#"posted");
}];
Hope this helps.