BrightcoveOS / PHP-MAPI-Wrapper

This project provides a starting point for integrating the Brightcove Media API into your application. It provides simple ways to interact with the API, as well as a long list of helper functions.
http://opensource.brightcove.com/project/PHP-MAPI-Wrapper/
48 stars 51 forks source link

Load All data from api #36

Open Krina opened 9 years ago

Krina commented 9 years ago

I have set 'page_size' => '150' as parameter but it loads all data instead of loading only 150 data.

page_size not affect to result.

Can you please help me how to do this?

Thnaks, Krina

rcrooks commented 9 years ago

@Krina

The maximum value allowed for page_size is 100. No individual request should ever return more than 100 items. Can you post the code here?

Robert

Krina commented 9 years ago

Hi Robert,

Please find below code

// Make our API call
$videos = $bc->find('allVideos');
// Determine how many possible results there are
echo 'Total Videos: ' . $bc->total_count . '
'; # Only return ID and Tags data $params = array( 'page_size' => '150', 'get_item_count' => 'FALSE', 'video_fields' => 'id,name,shortDescription,videoStillURL,tags,thumbnailURL,length,playsTotal,playsTrailingWeek,FLVURL', 'get_item_count' => 'FALSE', 'media_delivery' => 'http', 'sort_by' => 'PUBLISH_DATE', 'sort_order' => 'DESC', ); // Make our API call $videos = $bc->findall('video',$params); print_r($videos); exit();

Above code display 1087 items

rcrooks commented 9 years ago

this code:

// Determine how many possible results there are
echo 'Total Videos: ' . $bc->total_count . '
';

is displaying the total number of videos in the account -- that is not the number that is being returned by the API request.

Krina commented 9 years ago

No, When I print the array it shows me 1086 items. Can you please tell me how I can add pagination.

rcrooks commented 9 years ago

As I said, the maximum page_size is 100, but we recommend using 25 for better performance. So:

$params = array(
'page_size' => 25,
'page_number' => 4,

page_number is 0 based, so this would give you the 5th set of 25 videos