Reputation: 3008
I am trying to download my facebook inbox messages via php SDK 4 and save it to a database (using Guzzle for pagination). Pagination speed is very slow and also after certain time it hits api limit. What is the standard way to download my inbox message, also, how can I imporve pagination speed Here is my code for pagination :
function url($url){
$client = new Client();
$response=$client->get($url);
$body = $response->json();
return $body['paging']['next'];
}
$client = new Client();
$response = $client->get($x['comments']->paging->next);
$body = $response->json();
$url = $body['paging']['next'];
$count = 0 ;
while(true){
$result = url($url);
if(empty($result))
break;
echo $count . ": " . $result . "<br>";
$url = $result;
$count = $count + 1;
}
Upvotes: 0
Views: 866
Reputation: 74004
There is no other way except for using pagination and increasing the limit so you get more results per API call. But the limit parameter is...well...limited :) - So you cannot just use a limit of 1000.
Using the limit parameter would look like this: /me/inbox?limit=100
Keep in mind that you can only access your own inbox, you will not get read_mailbox
approved for your App:
This permission is granted to apps building a Facebook-branded client on platforms where Facebook is not already available. For example, Android and iOS apps will not be approved for this permission. In addition, Web, Desktop, in-car and TV apps will not be granted this permission.
Source: https://developers.facebook.com/docs/facebook-login/permissions/v2.2#reference-read_mailbox
Upvotes: 2