Facebook Connect for iPhone with a Session Proxy
I'm using the Facebook Connect for iPhone SDK at http://github.com/facebook/facebook-iphone-sdk/ and am trying to get the provided demo "Connect" app to work using a Session Proxy.
The iPhone shows the connect dialogue and gives my server a valid auth token which I pass to facebook. Facebook responds with a valid session key and session secret:
<auth_getSession_response xmlns="http://api.facebook.com/1.0/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://api.facebook.com/1.0/http://api.facebook.com/1.0/facebook.xsd">
<session_开发者_运维百科key>32fcxxx</session_key>
<uid>xxx</uid>
<expires>0</expires>
<secret>9f5xxx</secret>
<base_domain>example.com</base_domain>
</auth_getSession_response>
When not using the session proxy (which I need to use) the login works fine. Yet when I try the example using the session proxy, the example application returns with "Canceled login" (sic). No other part of the Facebook connect example codebase has been changed.
Is this a bug with the iPhone SDK or is there something extra I need to do for the iPhone to read the XML my server is returning?
I managed to fix this. As I was using Django, I had forgotten to set the proper XML headers required for the iPhone library to parse the response as XML.
tl;dr, make sure that your session proxy is outputting an actual XML file! http://hurl.it/ is great for debugging this sort of thing.
精彩评论