Facebook interests list not getting iOS - ios

I am using SLRequest to get basic profile info. For getting interests i am using user_interests permission and the following code,
NSURL *meurl = [NSURL URLWithString:[NSString stringWithFormat:#"https://graph.facebook.com/me/interests"]];
SLRequest *merequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:meurl
parameters:nil];
merequest.account = _facebookAccount;
[merequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSError * error1=nil;
NSDictionary *responseJSON = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error1];
}];
But the above code gives the empty response like as follows,
{
"data": [
]
}
Can anyone give the solution for this problem. Thanks.

There could be only 2 possible reasons for this-
There are no interests of the user queried (as #Tobi has mentioned), or
Your access token used by your api call do not have the permissions user_interests. This could be because you've added this permission later and since the session was active it didnt asked for the new permission.
You can check what permissions you've granted to the app from here
If this is the problem, you can either logout from the facebook in your app and login again or delete the app from here so that it will ask for the authorization again.
Hope that helps. Good luck

Related

How can I test facebooks friends tagging

I want my app to tag friend within a video-post.
(Posting a video without the tags is working fine)
The account I'm using, has been added to the list of testers for my app.
So I should be able to do this call without any permissions.
But the response is still:
"error: (#3) Application does not have the capability to make this API call."
To get the "Taggable Friends" permission, I need upload a build of my app to fb.
But I can't implement this feature without testing it by myself first.
How can I solve this chicken-and-egg problem?
My code looks like this (iOS - Objc):
NSDictionary *params = #{
#"title": #"some title",
#"description": #"some desctiption",
#"tags": _friendId
};
SLRequest *uploadRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:videourl
parameters:params];
I have found the solution.
You can't set the tag whithin the upload request (I still don't know why).
But you can tag a user in the video after you uploaded the video.
When the upload succeeded, you get a videoId:
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData
options:NSJSONReadingMutableContainers
error:&error];
_currentVideoId = json[#"id"];
With this id you can make a second request:
ACAccountCredential *fbCredential = [_facebookAccount credential];
NSString *accessToken = [fbCredential oauthToken];
NSString *urlStr = [NSString stringWithFormat: #"https://graph-video.facebook.com/%#/tags?access_token=%#&tag_uid=%#", _currentVideoId, accessToken, userId];
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:[NSURL URLWithString: urlStr]
parameters: #{}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
//Do something
}];
});
To make the second request, you need the permission for #"user_videos".
If you want to tag more users, you need to make this request a few times. Maybe it's also possible with one request, but I didn't figuered out how to do it yet.

Like a facebook page using ios 6.0 social api

I want to implement like a page functionality using ios 6.0 social api. I think if I get exact Facebook Graph API link for like functionality then it possible. But I am not getting what's the exact url. Many are saying that it's not possible. I would like to know exact answer.
Please check and below code and response from Facebook.
{
"error": {
"message":"(#100) Like actions are not yet supported against objects of this type.",
"type":"OAuthException",
"code":100
}
}
Code :
NSURL *meurl = [NSURL URLWithString:#"https://graph.facebook.com/me/og.likes?"];
NSDictionary *param = [NSDictionary dictionaryWithObjectsAndKeys:account.credential.oauthToken,#"access_token",#"https://www.facebook.com/sample",#"object", nil];
SLRequest *merequest = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodPOST URL:meurl parameters:param];
merequest.account = account;
[merequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *response = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(#"%#",response);
}];

how to retrieve Facebook friend's group name?

Facebook SDK 3.+ has requestForMyFriends, and return FBGraphUser but it doesn't have a group name property, is there a way to get all the groups belongs to the user?
You could easily grab all of a user's groups using the FB Open Graph and SLRequests. Ensure that you've already authenticated and then make the call like this:
NSURL *groups = [NSURL URLWithString:#"https://graph.facebook.com/me/groups"];
SLRequest *retrieveGroups = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:groups parameters:nil];
[retrieveGroups performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
//responseData contains your groups
}];

ios6 Tweet via SLRequest and edit the source field

I'm trying to edit the "source" field of a tweet that's documented: https://dev.twitter.com/docs/platform-objects/tweets
The below code successfully posts a tweet, however when I pull up that tweet on tweetdeck it still says it's being posted via ios. It feels like NSDictionary isn't the place to be editing this, however it doesn't seem like there's a better place in the flow and I can't find any examples/documentation to clear it up. Thanks for any help in advance.
NSDictionary *message = #{#"status": contents,
#"source": #"App Name"};
NSURL *requestURL = [NSURL
URLWithString:#"http://api.twitter.com/1/statuses/update.json"];
SLRequest *postRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodPOST
URL:requestURL parameters:message];
postRequest.account = twitterAccount;
[postRequest performRequestWithHandler:^(NSData *responseData,
NSHTTPURLResponse *urlResponse, NSError *error)
{
NSLog(#"Twitter HTTP response: %i", [urlResponse
statusCode]);
}];
The documentation you're referring to explains the meaning of returned fields.
You cannot set the source by yourself, there's no API for that.
You can find the POST statuses/update API here.
Additionally, the code you posted uses API version 1 which was shut-down a while ago.
Now you have to use API version 1.1.

iOS Post to Facebook wall mention tag user

I want to make a post from my iOS app with a mention to some friends. I got his "id".
So i use the follow and isn't work:
NSString *textToShare = #"hello #[100003626828741]";
NSDictionary *parameters = #{
#"picture":picture,
#"name" : #"hello",
#"caption" : textToShare,
#"message" : textToShare,
};
NSURL *feedURL = [NSURL URLWithString:#"https://graph.facebook.com/me/feed"];
SLRequest *feedRequest = [SLRequest
requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:feedURL
parameters:parameters];
feedRequest.account = [[ICollinaService instance] facebookAccount];
[feedRequest performRequestWithHandler:^(NSData *responseData,
NSHTTPURLResponse *urlResponse, NSError *error)
{
NSLog(#"Facebook HTTP response: %i", [urlResponse
statusCode]);
NSLog(#"Facebook HTTP response allHeaderFields: %#", [urlResponse
allHeaderFields]);
NSLog(#"Facebook HTTP error: %#", error);
}];
}
How can i mention a friend in my post?
Thanks
The result of the post is: hello #[100003626828741] as a caption and message, without changeing the id for the name with link/tag.
I don't think you can tag a friend in a post, but you can in an action.
I'm looking into the Facebook Open Graph API - https://developers.facebook.com/docs/opengraph/getting-started/
I dont know if this is the best way to go!?!
I find it disturbing that its easy to pick friends with friendPicker and post pictures is extremely easy with IOS 6.0 social framework but to post the two combined with open Graph seems very difficult in comparison. Its however the only solution I have found so far.

Resources