Greg Lukosek
Greg Lukosek

Reputation: 1792

Unity FB.API request returning unsupportedURL on iOS, working in editor

Im requesting basic data from Unity app using official Facebook SDK. The problem appears when I add first_name field into friends list

There is no issue in Unity Editor, problem only appears on iOS, console screaming UnsuportedURL

Issue does not appear without the {first_name} right after friends

Request:

me?fields=id,name,friends{first_name}

Unity Code:

FB.API("me?fields=id,name,email,friends{first_name},first_name", HttpMethod.GET, delegate(FBResult dataResult) {

        if (!string.IsNullOrEmpty(dataResult.Error)) {
            //error occured
            Debug.LogError(dataResult.Error);
            error(dataResult.Error);
            isFinished(true);

        } else {

            Debug.Log(dataResult.Text);
        }

Upvotes: 1

Views: 606

Answers (3)

Steve Ellis
Steve Ellis

Reputation: 1

Using the following query:

"/me?fields=id,first_name,gender,picture,email,friends{id,first_name,gender,picture},invitable_friends{id,first_name,picture}"

... works fine in the Unity Editor but not on iOS. The previous solutions don't work.

Switching from curly brackets to regular brackets - Facebook rejects it for containing an invalid character.

Switching to escaped curly brackets (%7B and %7D) - Still returns Unsupported URL.

Here's how I fixed it in the end:

"me?fields=id,first_name,gender,picture,email,friends.fields(id,first_name,gender,picture),invitable_friends.fields(id,first_name,picture)"

Upvotes: 0

Greg Lukosek
Greg Lukosek

Reputation: 1792

Looks like curly braces are the issue here breaking iOS NSURL

Escaping curly braces worked like here: NSURL with Curly Braces

"me?fields=id,name,email,friends%7Bfirst_name%7D,first_name"

Upvotes: 0

Swinny89
Swinny89

Reputation: 7373

Try this URL, using fields.

"me?fields=id,name,email,friends.fields(first_name),first_name"

Upvotes: 1

Related Questions