Quote:
Originally Posted by harpreetxi
Trying to create a advert. Using their json api but that file is too big, it hang whole server. It fetches 3000+ models info at once.
I was asking them if there is a way to do pagination or if they can provide me less models in the api, let's say 50-60, models maybe. This would make things fast and I can proceed with it
|
The pagination has to be done on our end. Something like that:
Code:
$affid = 12345;//your cb affiliate id
function get_cb_list($nb=50, $page=1) {
$offset = ($nb * $page) - $nb;
$memcache = new Memcache;
$memcache->connect(‘x.x.x.x’, xxxxxx);
$cachedModels = $memcache->get(‘XXXX’);
if ($cachedModels) {
$results = $cachedModels;
} else {
$listUrl = 'https://chaturbate.com/affiliates/api/onlinerooms/?format=json&wm=$affid;
$content = file_get_contents($listUrl);
$results = json_decode($content);
$memcache->set('XXXX', $results, MEMCACHE_COMPRESSED, 120);
}
return array_slice($results, $offset, $nb);
}
Every time you call that function it returns 50 models, and it only calls the cb remote server once (unless you call the function for over 2 minutes). This is php, your hosting company can help you with the memcache info.
Best of luck!