问题
I'm trying to change the format of the result i get from the facebook graph api to XML.
I use the format=xml parameter but that don't seem to work for me.
https://graph.facebook.com/me&access_token=xxxxxxxxxxxx&format=xml
The result is shown in Json format :(
Is it still posible to use the xml format?
回答1:
The new graph api always returns data in json.
XML has an overhead on communication size and processing required for parsing so it's being dropped from web API's.
回答2:
That's part of the old api. Graph api will return JSON objects (which, in my opinion, are much better suited for the job anyway). Verbatim from the facebook graph API documentation:
All responses are JSON objects.
http://developers.facebook.com/docs/reference/api/
回答3:
Facebook to XML. Firstly reference Newtonsoft.Json.net
using Newtonsoft.Json;
for example...
var facebookJson = fb.Get("/me");
then...
XmlNode facebookUserObjxml = (XmlNode)JsonConvert.DeserializeXmlNode("{\"root\":" + facebookJson.ToString() + "}", "root");
回答4:
Use this:
$fbInfoUrl = "http://graph.facebook.com/".$token;<br/>
$fbInfo = file_get_contents($fbInfoUrl);<br/>
$fbInfoObj = json_decode($fbInfo, true);<br/>
You'll get an Object in XML format in $fbInfoObj.
来源:https://stackoverflow.com/questions/5540322/set-result-format-of-facebook-graph-api-to-xml-instead-of-json