Ejemplo n.º 1
0
/**
 * Constructs a URL to get live remote assets from Ooyala API
 * @param integer $apiPageSize
 * @param integer $page
 * @param string $provider
 * @param string $keyword
 * @return string $url
 */
function getApiAssets($apiPageSize, $page, $provider, $keyword)
{
    $cond = array("status = 'live'", "asset_type = 'remote_asset'", "metadata.source = '{$provider}'");
    if (!empty($keyword)) {
        $cond[] = "metadata.keywords = '{$keyword}'";
    }
    $params = array('limit' => $apiPageSize, 'where' => implode(' AND ', $cond));
    if (!empty($page)) {
        $parsed = explode("?", $page);
        parse_str(array_pop($parsed), $params);
    }
    $method = 'GET';
    $reqPath = '/v2/assets';
    $url = OoyalaApiWrapper::getApi($method, $reqPath, $params);
    return $url;
}
Ejemplo n.º 2
0
 /**
  * Send request
  * @param string $method
  * @param string $reqPath
  * @param array $params
  * @return boolean $result
  */
 protected function sendRequest($method, $reqPath, $params = [])
 {
     wfProfileIn(__METHOD__);
     $reqBody = empty($params) ? '' : json_encode($params);
     $url = OoyalaApiWrapper::getApi($method, $reqPath, [], $reqBody);
     //print( "Connecting to $url...\n" );
     $options = ['method' => $method, 'postData' => $reqBody, 'noProxy' => true];
     $req = MWHttpRequest::factory($url, $options);
     $status = $req->execute();
     if ($status->isGood()) {
         $result = true;
         print "Ooyala: sent {$reqPath} request: \n";
     } else {
         $result = false;
         print "ERROR: problem sending {$reqPath} request (" . $status->getMessage() . ").\n";
     }
     wfProfileOut(__METHOD__);
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * get feed url
  * @param array $params
  * @param string $nextPage
  * @return string $url
  */
 private function initFeedUrl($params, $nextPage)
 {
     $method = 'GET';
     $reqPath = '/v2/assets';
     if (!empty($nextPage)) {
         $parsed = explode("?", $nextPage);
         parse_str(array_pop($parsed), $params);
     }
     $url = OoyalaApiWrapper::getApi($method, $reqPath, $params);
     return $url;
 }