How to download multiple facebook avatars with fast speed?

Sure.

Anything else?

The most strange is that the first request works. And I’m doing all requests as the same way.

Check the marked response. As I mentioned before to try the Batch API endpoint.

Try do a test request with 3 or 4 avatar GETs and see if it works

Also… how long is the wait before the timeout comes in? You can configure default timeout values on the request. - more info in the FB documentation

I think I’m using the default time because I never setted it.
It seems to be 10sec. Do you know the method for edit it? I tried with:
network::HttpClient::getInstance()->setTimeoutForRead(60); without results.

Anyway, 10sec for a very popular server like facebook, i think is sufficient…

I think the FB request has a timeout parameter object configurable to the FB server side, not your actual request from client. I’m not sure what default is there. check documentation

Also from FB documentation:

Making Multiple Requests

The standard version of the Graph API is designed to make it easy to get data for an individual object and to browse connections between objects. It also includes a limited ability to retrieve data for a few objects at the same time.

If your app needs the ability to access significant amounts of data at once, or you need to make changes to several objects at once, it is often more efficient to batch your queries rather than make multiple individual HTTP requests.

To enable this, the Graph API supports a number of functions, including multiple-ID lookup and batching. Batch requests are explained in a separate guide but you can read more about multiple ID lookup below.

Everything leads to my first post on this thread about batching the request.

But it’s very strange, I’ve only 5 friends! And they return me only 1 avatar. I’m not requesting a lot of avatars. Two possibilities:

  1. Their server is too slow.
  2. They’ve an strict flood protection, haha

I think it is more so your second possibility. I don’t even want to begin to comprehend how many requests are received at Facebook every second.

@tranthor You should try out the API requests outside of your application/game, just so you can rule out your app as the issue, and possibly narrow down the reasons why it’s not working as you expect it to.

I strongly suggest that you use something like Postman to do this (if you aren’t already using it). It’s free, and you have the option of using the standalone app or a plugin for Chrome. Create your requests in it, then fire them off to the Facebook API at about the same rate you would expect your own app to do this, and see what happens.

This may help too: mocky.io

1 Like

UP.
I’m trying to download all FB avatars with only 1 request. I mean, I would like to create all Avatars-Sprite with only one request to Facebook. But I can’t.
I’ve all avatars-urls and according to the documentation, i’m sending the batch data via POST to https://graph.facebook.com but the json response doesn’t contain the information for construct each Sprite.

Data that I’m sending via POST:

{
“batch”: [
{
“method”: GET
“relative_url”: http://…url to the direct download to avatar-image
},
{
“method”: GET
“relative_url”: http://…url to the direct download to avatar-image
}
],
“access_token”: “…”
}

Example of data response that I receive:

[{
“code”: 200,
“headers”: [{
“name”: “Expires”,
“value”: “Sat, 01 Jan 2000 00:00:00 GMT”
}, {
“name”: “Cache-Control”,
“value”: “private, no-cache, no-store, must-revalidate”
}, {
“name”: “Access-Control-Allow-Origin”,
“value”: “ "
}, {
“name”: “Pragma”,
“value”: “no-cache”
}, {
“name”: “Strict-Transport-Security”,
“value”: “max-age=15552000; preload”
}, {
“name”: “ETag”,
“value”: ““3f2ef278dacb9dfc1c3827404a99ad8dfedc20cd””
}, {
“name”: “Vary”,
“value”: “Accept-Encoding”
}, {
“name”: “X-App-Usage”,
“value”: “{“call_count”:10,“total_cputime”:0,“total_time”:0}”
}, {
“name”: “Content-Type”,
“value”: “text/javascript; charset=UTF-8”
}, {
“name”: “Facebook-API-Version”,
“value”: “v2.12”
}],
“body”: “{“id”:“https://platform-lookaside.fbsbx.com/platform/profilepic”}”
}]

Example of the responseData that I need for construct 1 sprite: **\377\330\377\340
That’s the response when I make a GET-request with only 1 URL. Why this information isn’t in the json (for each player) when I try to request all avatars?

:confused:

Maybe this info can help. Check the section down the bottom of that page with the section title “Named requests”, where there is an example for retrieving 3 profile pictures at once.

@R101 thanks for your help! But I don’t understand what modification should I do in the request-json that I shared in my last post. I’m using the same as that example… method GET, relative_url…

I didn’t notice that earlier, but is there any reason you’re using v2.12 of the API? Have you tried the newer endpoints (like v3.3)?

I’m using sdkbox and I tried updating to the last sdkbox-facebook-sdk version.
Same results. Maybe sdkbox-fb is out of date? @htlxyz
Are you sure that it could be a version problem @R101 ? :confused:
The POST that i’m doing is to the url https://graph.facebook.com
Maybe you know other endpoint / url?

I’m slightly confused now. Have you actually attempted to send the batch request with the Postman app to see what response you get from the API?

The only reason I’m asking is that you’re still referring to your app, so I’m not clear on whether the requests actually do work outside of your app or not.

If the batch request works in Postman, then at least you’ve narrowed down the issue to your application, and if the batch request does not work, then you know that it is something external to your application that is causing this issue.

Just do a net search for the Facebook API. It’s documented very well by Facebook.

@R101 I sent to you in PM some of the links that i’m requesting to FB.