phpzencoder

How to page through zencoder-php job index


I have been attempting to page through zencoder-php job indexes, based off the library source code taking an array for the first and second argument, but I am unsure on how the array arguments have to be written to go through as many job indexes as possible. I have been unable to find an example for this, so I am attempting to go off of the zencoder-py documentation, which is entirely different. I only have been able to get the first page of job details every time I rewrite the arguments to pass.

This is what I have written so far:

for ($page_number = 0; $page_number < 10000; $page_number++){

    $job_index = $l_xZencoder->jobs->index(array(), array('page='.$page_number)); 

    foreach($job_index as $job){...}
}

Solution

  • With the help of Zencoder support they provided the answer to my question. I looked over the source code and did not catch the PHP function http_build_query:

    The URL parameters should be set to the $args parameter, and the $params parameter should be blank.

    You could submit your API request as follows:

    $page_number = 4; $page_size = 50;

    $encoding_jobs = $zencoder->jobs->index(array('page'=>$page_number, 'per_page'=>$page_size), array());

    If you could look into the source code for Zencoder PHP library, you would see a line "http_build_query($params, '', '&'))" which $params is used to create the actual URL parameters that are added to the API.

    https://github.com/zencoder/zencoder-php/blob/master/Services/Zencoder.php