I believe your question is how to execute a batch request using the Facebook Graph API. To do this, you need to send a POST request for
"https://graph.facebook.com"
and the data sent must be
"batch=[{'method': 'GET', 'relative_url': 'me'}, {'method': 'GET', 'relative_url': 'me/friends?limit=50'}]& access_token=@accesstoken "
in your case [@accesstoken needs to be replaced with the access token value].
This request will return information about the owner of the access token (usually the current user in the system) and a list of 50 facebook friends (contains the id and name fields) of the user along with the page headers (can be omitted).
I'm not sure if you meant java or Javascript. Please be specific.
I am a C # programmer. Provides you the code to execute the above request in C # here.
WebRequest webRequest = WebRequest.Create("https://graph.facebook.com"); webRequest.Method = "POST"; webRequest.ContentType = "application/x-www-form-UrlEncoded"; byte[] buffer = Encoding.UTF8.GetBytes("batch=[{'method': 'GET', 'relative_url': 'me'}, {'method': 'GET', 'relative_url': 'me/friends?limit=50'}]& access_token=@ACCESSTOKEN "); webRequest.ContentLength = buffer.Length; using (Stream stream = webRequest.GetRequestStream()) { stream.Write(buffer, 0, buffer.Length); using (WebResponse webResponse = webRequest.GetResponse()) { if (webResponse != null) { using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8)) { string data = streamReader.ReadToEnd(); } } } }
Here the data strong> variable will contain the result.
source share