Accessing privacy settings of Facebook post (open graph action) - ios

My app has the publish-permission:"publish_actions" and the read-permissions: "public_profile", "email", "user_posts".
After posting an open graph action i want to find out what visibility setting the post has (private, friends, public).
I am calling the following method (Swift)
let request2 = FBSDKGraphRequest(graphPath: "postid", parameters: nil, HTTPMethod: "GET")
request2.startWithCompletionHandler(...)
EDIT:
i receive the following response:
{
data = {
location = {
id = 00000000000;
title = "Sample title";
type = "my_namespace:location";
};
};
"end_time" = "2016-02-01T09:35:35+0000";
id = postid;
"start_time" = "2016-02-01T09:35:35+0000";
type = "my_namespace:check_in";
}
So there does not seem to be a privacy information i get from the post.
Is there a way to get it? According to developers/facebook there should be a privacy field.

So this took me forever to find out. Here is the solution:
When you post an Open Graph Story you get an id as response. This id alone however will not be sufficient when retriving info about it. You need to append the facebook user id at the beginning of the received postid. So the correct id is "userid_opengraphpostid" (underscore needed). The you can make the request with the parameter ["fields":"privacy"] (swift, ios).

Related

Facebook all_mutual_friends not working

I'm building an iOS app that connects to Facebook's all_mutual_friends API
https://developers.facebook.com/docs/graph-api/reference/user-context/all_mutual_friends/
The app has been reviewed and approved to connect to this API.
When I make the graph call per the documentation:
let params = ["fields":"context.fields(all_mutual_friends.fields(picture.width(500).height(200)))"]
FBSDKGraphRequest(graphPath: "/\(facebookID)", parameters: params, HTTPMethod: "GET").startWithCompletionHandler { (connection, result, error) in
print("result: \(result)")
print("error: \(error)")
}
I get the following result:
result: {
context = {
id = dXNlcl9jb250ZAXh0OgGQ8qbGU5YUiZAKn8g4zuCb1LCMGj3PiCXfe7B72X5DoKkbMpHZA395xRT0iV8D84NQIZBCjJ3VRKC9uNUrMZCiwIeZBOSTRndZCQKi4pgiIgLoxI3xAZD;
};
id = 10208913134493418;
}
The above response is when we have a mutual friend who has the app installed.
Does anyone know how to get the list of mutual friends?
If I am Facebook friends with the person, I successfully receive a list of mutual friends making the same graph call. This is the response:
context = {
"all_mutual_friends" = {
data = (
{
"first_name" = Mary;
picture = {
data = {
height = 200;
"is_silhouette" = 0;
url = "https://...";
width = 200;
};
};
}, //... 24 more results
This is great because there is data, but it is limited to 25 mutual friends. Is there a way to increase the limit above 25?
According to the Facebook documentation you referred above :
The All Mutual Friends API must be called from your server to obtain the full list of mutual friends. Calling this API in JavaScript, Android, or iOS client code will omit some of the results.
This explains the limit you are facing. :)

iOS: Get Latest Tweet Text Only From Specific User

I am wanting to get the latest tweet from a specific user that will not change. So if the specific user was Joe Smith, I would always get the latest tweet from him. I've looked into Fabric which seems to only get specific tweets by ID. The Twitter API looks fairly involved when all I am wanting is the latest tweet from a user. What is the best way to do this?
you could achive this by searching for a user and only using th first element
Using from:#tweethandle for example: from:StackOverflow and using only the first item!
You can search using TWTRAPIClient's URLRequestWithMethod
Ex: (using SwiftyJSON for parsing JSON) this should print the first tweet
let twError:NSErrorPointer = nil
let userID = Twitter.sharedInstance().sessionStore.session()?.userID
let client = TWTRAPIClient(userID: userID)
let request = client.URLRequestWithMethod("GET", URL: "https://api.twitter.com/1.1/search/tweets.json", parameters: ["q":"from:StackOverflow","result_type":"recent"], error: twError)
if twError == nil {
client.sendTwitterRequest(request, completion: { (response, data, error) -> Void in
let json = JSON(data: data!)
print(json["statuses"][0])
})
}
More info in the docs

Retrieveing media liked by the user returns nothing

I'm trying to get the media liked by the logged in user. I do the authentication process and get an access token like this.
1312564049.dd97f3a.e9gw8d5516414d348c0b34f328e80fb1
I made sure to ask for public_content scope permission as well.
Then I call the /users/self/media/liked endpoint passing this token.
let urlString = "https://api.instagram.com/v1/users/self/media/liked"
let params = ["access_token": token]
Alamofire.request(.GET, urlString, parameters: params, encoding: .URL, headers: nil).responseJSON { response in
print(response.description)
}
But I get the following as the result.
{
data = (
);
meta = {
code = 200;
};
pagination = {
};
}
There are many photos liked by the user account I use. So I'm baffled why this returns empty. Is this because I'm in sandbox mode? Or something wrong with this endpoint? Because I checked /users/self and /users/self/media/recent and they both returned results.
Its because of the sanbox mode.
https://www.instagram.com/developer/sandbox/
Data is restricted to the 10 users and the 20 most recent media from each of those users

get all facebook contacts with swift

I'm trying to get all my facebook contacts. With this code managed to catch however I can not bring the phone information and email contacts. This is my code:
let params = ["fields": "first_name, last_name, name, email, picture, phone"]
let request = FBSDKGraphRequest(graphPath:"/me/taggable_friends", parameters: params);
request.startWithCompletionHandler { (connection : FBSDKGraphRequestConnection!, result : AnyObject!, error : NSError!) -> Void in
if error == nil {
self.appDelegate.dismissHUD()
let resultdict = result as! NSDictionary
self.fbContact = resultdict.objectForKey("data") as! NSArray
print(self.fbContact)
self.loadData()
} else {
self.appDelegate.showError("Time Out")
}
it returns this dictionary:
(
{
"first_name" = xxxx;
id = "AaJRSpI-fYgIaPMaJCHEgCHB59aRecZbRSx0BrvDR_bZV-1W873iXn34kU940C_hc-TaoPnuFDfsJbBYtDSAFWiBfGWBXbxOja0c3NIHhyFqoQ";
"last_name" = xxxx;
name = "xxxx xxxx";
picture = {
data = {
"is_silhouette" = 0;
url = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfa1/v/t1.0-1/p50x50/10351160_1463351673922060_1213695234585630315_n.jpg?oh=4c3b52137fc70b5743c7d00c2d=56ECD8DC&__gda__=1456979546_a879ab411cdf61e9293f27f70cd43bdd";
};
};
}
)
This is a facebook Graph API limitation. There is some limitations on the data you can get depending on the role you are. You cannot get your friends email or phone using Graph API.
taggable_friends can ONLY be used for tagging, it does not include any other data. You can only get additional data of friends who authorized your App too.
Btw, you can´t even get the phone of the authorized user, there´s no way to get it at all. And for the email, you have to authorize a user with the email permission.
In general, you can´t get any data of users who did not authorize your App, for privacy reasons.

How to get Facebook page cover photo using iOS SDK

How to get Facebook page cover photo using iOS SDK,
From the parsed json result I am getting , the below result but, couldn't get cover photo from there .
{
actions = (
{
link = "https://www.facebook.com/100007281559316/posts/1487360021516702";
name = Comment;
},
{
link = "https://www.facebook.com/100007281559316/posts/1487360021516702";
name = Like;
}
);
"created_time" = "2014-10-10T04:09:22+0000";
description = "Loneliness is a good feeling when it is created by Ourself. But . .it is the worst feeling when it is Gifted by others.\nExpecting your Opinion ekantatha#gmail.com";
from = {
id = 100007281543425252416;
name = "Hari Krishna";
};
icon = "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif";
id = "100007281559316_1487360021516702";
link = "https://www.facebook.com/Ekantatha";
message = "https://www.facebook.com/Ekantatha";
name = "\U0d0f\U0d15\U0d3e\U0d28\U0d4d\U0d24\U0d24";
picture = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfp1/v/t1.0-1/c6.0.200.200/p200x200/1779801_631456453593885_482158404_n.jpg?oh=8f766377fc71b8e3703e330067a70ebc&oe=54C1FF93&__gda__=1421213700_5f4ec6aea535e630c1a5a1eace45f34b";
privacy = {
allow = "";
deny = "";
description = "Only Me";
friends = "";
networks = "";
value = SELF;
};
properties = (
{
name = Community;
text = "1,102 like this";
}
);
"status_type" = "shared_story";
type = link;
"updated_time" = "2014-10-10T04:09:22+0000";
}
Edit :
I want to display my cell like this so I needed cover photo for this. from the json result I am not getting the page Id. How can I get the cover photo of the page by using iOS SDK ?
Here is an updated solution.
var basicUserData = ["fields": "cover,picture,id,birthday,email"]
FBRequestConnection.startWithGraphPath("/me",
parameters: basicUserData,
HTTPMethod: "GET") {
(connection:FBRequestConnection!, result, error) -> Void in
if error != nil {
print(error!)
} else {
print(result!)
}
}
The Parse team recommended getting FB profile picture by accessing the https://graph.facebook.com/(facebookId)/picture?type=large Make sure to replace with the user's Facebook Id. Here is the discussion
Notes:
username field is deprecated after FacebookSDK v2
"/me" is the correct endpoint not "me"
This gist shows many other interactions with the Facebook Graph
For IOS;
I have used https://graph.facebook.com/facebookuserid?fields=cover link but it did not work. When I search Facebook SDK documentation, I see the answer that works. I hope this will be helpful for you.
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:#"/%#?fields=cover", [user objectForKey:#"id"]]
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
NSLog(#"%#",[[result objectForKey:#"cover"]objectForKey:#"source"]);
/* handle the result */
}];
Result is a type of a Dictionary. You can see the link of user's cover photo under "cover" tag and its "source" tag also.
That's a post JSON you're showing here, which has nothing to do with requesting the Page's cover.
The latter can be done via calling
GET /{Page_ID/?fields=id,name,cover
where {Page_ID/ is the ID or the name of the Page in question. For CocaCola, the result looks like
{
"id": "40796308305",
"name": "Coca-Cola",
"cover": {
"cover_id": "10152297032458306",
"offset_x": 0,
"offset_y": 0,
"source": "https://fbcdn-sphotos-f-a.akamaihd.net/hphotos-ak-prn2/v/t1.0-9/s720x720/625442_10152297032458306_574021701_n.jpg?oh=54a129979e8786632b41e445db571749&oe=54B094E9&__gda__=1421627392_0061b39b7d81a3356a2b8a82a65b3839"
}
}

Resources