View Single Post
Old 07-17-2020, 12:10 PM  
drexl
Whale Hunter
 
drexl's Avatar
 
Industry Role:
Join Date: Jan 2016
Posts: 945
Quote:
Originally Posted by harpreetxi View Post
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!
__________________
drexl is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote