Using WWW / Unity3 and Making Calls to Facebook OpenGraph API


I was wondering if it was possibly to make calls to the Facebook OpenGraph API, so my code is what's wrong.

Basically, is this Unities security, or is it my code...

Everything I do, will not return the correct data

IEnumerator Load()
    //Security.PrefetchSocketPolicy("", );

    while (!CookieCutter.IsLoaded())
        yield return StartCoroutine(WebUtils.WaitFor(0.1f));

    string cookieValue = CookieCutter.GetCookie(theLimitCookieName);

        cookieValue = CookieCutter.GetCookie(debugCookieName);  

    // --- Hash the cookie values
    if (!string.IsNullOrEmpty(cookieValue))
        cookieValue = cookieValue.Trim('\"');

        string[] nameValues = cookieValue.Split('&');

        Hashtable hashTable = new Hashtable();

        foreach (string element in nameValues)
            string[] splitElement = element.Split('=');

            if(splitElement.Length == 2)
                hashTable[splitElement[0].Trim('"')] = splitElement[1].Trim('"');

        long.TryParse((string)hashTable["uid"], out _uid);

        _accessToken = (string)hashTable["access_token"];


            t = "LoadFriends : " + UID;

    // --- Now lets do a web call
    WWW fbFriendsReq = new WWW("" + UID);

    yield return WebUtils.WaitForRequest(fbFriendsReq);

// --- these calls never return the correct data...isDone = false, and error is undefined

    t = "Returned from WebUTils : Done : " + fbFriendsReq.isDone + "  Error : " + fbFriendsReq.error;

    t = "Recieved Friends : " + fbFriendsReq.text; 

// --- Execution never makes it here

    _friends = FacebookFriends.CreateFromJSON(fbFriendsReq.text);

    t = "Friends Created From JSON";

    yield return WebUtils.WaitFor(0.01f);

The server you're connecting to would need to respond with a policy file that gives the Unity Web Player permission. So unless you can convince Facebook to put up a security file for all us Unity folks you're going to have to resort to the standard, call out to the enclosing web page trick.

I see that... Security.PrefetchSocketPolicy("", 8080) is most likely the call I need to make. but what happens is that PrefetchPolicy returns false... ALWAYS...

This is the

Is there something invalid about this domain policy?

Is my code bad above to do a web request?

This code used to work with Unity2.6, and I'm handling all your new security stuff...I just can't get it to work.

There is always the work around of reading it through my ASP page and sending it in through UnityObject.SendMsg...thus I can get around all of unity's "security"....

Also, This cross domain stuff, isn't really that secure....

Say I need to use Texture.SetPixel()... What I can do, is send it to myself, through a web-call, in my own IIS server.

For example :""

and this Http request just returns the image... the image is coming from my own domain, and I can modify it with SetPixel.

I just circomvented any security you implemented...I know this works, because I've done it with flash.

Anyways, Why doesn't the WWW call work in the original post? Is there something fundamentally wrong with the WWW code? Can I expect that the line after yield return WWWcall, has a valid Object?

Thanks, stringa

Is there something wrong with this crossdomain policy, that isn't supported by Unity?

<?xml version="1.0" ?> 
  <!DOCTYPE cross-domain-policy (View Source for full doctype...)> 
  <allow-access-from domain="*" secure="false" /> 
  <site-control permitted-cross-domain-policies="master-only" /> 

PrefetchSocketPolicy needs an IP address, host name willn’t work.