I’m trying to add a Facebook friend list to my Swift iOS app using the Graph API.
I’m struggling to work out how to actually access the data that’s being send back from Facebook.
The response I get looks like this:
success(FacebookCore.GraphResponse(rawResponse: Optional({
"first_name" = Jamie;
id = 1626917907360895;
"last_name" = McAllister;
name = "Jamie McAllister";
picture = {
data = {
height = 50;
"is_silhouette" = 0;
url = "https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/12994335_1101318013254223_4481895970110564364_n.jpg?oh=d10209f113213981e4417e7f6f3f82d8&oe=5A91F135";
width = 50;
};
};
})))
My graph Request is just /me
for now as I’m the only registered user. But all the fields in the response are what I will be requesting from the friends list
The graph request looks like this:
var graph = GraphRequest.init(graphPath: "me")
graph.parameters = ["fields": "id, first_name, last_name, middle_name, name, email, picture"]
graph.start({ (response, data) in
print("======GRAPH=====")
print(data)
})
So, I want to be able to take the GraphResponse
, make it an Array and assign it to a variable. I am completely stumped by this one.
3
Answers
To read response from Facebook Graph Request use the below line of codes
Hope this will help you
Hope this Helps
Swift 4.2
The Graph request start completion block has changed to requiring 3 arguments instead of 2.
So you will have something like this (NOTICE THERE ARE NOW 3 ITEMS PASSED IN THE START BLOCK [connection, result, and error]):