Dailymotion.php
public function call($resource, $args = array())
    {
        $headers = array('Content-Type: application/json');
        $payload = json_encode(array(
            'call' => $resource,
            'args' => $args,
        ));
        $statusCode = null;
        try
        {
            $result = json_decode(
                $this->oauthRequest(
                    $this->apiEndpointUrl,
                    $payload,
                    $this->getAccessToken(),
                    $headers,
                    $statusCode
                ),
                true
            );
        }
        catch (DailymotionAuthException $e)
        {
            if ($e->error === 'invalid_token')
            {
                // Retry by forcing the refresh of the access token
                $result = json_decode(
                    $this->oauthRequest(
                        $this->apiEndpointUrl,
                        $payload,
                        $this->getAccessToken(true),
                        $headers,
                        $statusCode
                    ),
                    true
                );
            }
            else
            {
                throw $e;
            }
        }
        if (empty($result))
        {
            throw new DailymotionApiException('Invalid API server response');
        }
        elseif ($statusCode !== 200)
        {
            throw new DailymotionApiException("Unknown error: {$statusCode}", $statusCode);
        }
        elseif (is_array($result) && isset($result['error']))
        {
            $message = isset($result['error']['message']) ? $result['error']['message'] : null;
            $code    = isset($result['error']['code'])    ? $result['error']['code']    : null;

            if ($code === 403)
            {
                throw new DailymotionAuthRequiredException($message, $code);
            }
            else
            {
                throw new DailymotionApiException($message, $code);
            }
        }
        elseif (!isset($result['result']))
        {
            throw new DailymotionApiException("Invalid API server response: no `result` key found.");
        }
        return $result['result'];
    }
public function call($resource, $args = array())
    {
        $headers = array('Content-Type: application/json');
        $payload = json_encode(array(
            'call' => $resource,
            'args' => $args,
        ));
        $statusCode = null;
        try
        {
            $result = json_decode(
                $this->oauthRequest(
                    $this->apiEndpointUrl,
                    $payload,
                    $this->getAccessToken(),
                    $headers,
                    $statusCode
                ),
                true
            );
        }
        catch (DailymotionAuthException $e)
        {
            if ($e->error === 'invalid_token')
            {
                // Retry by forcing the refresh of the access token
                $result = json_decode(
                    $this->oauthRequest(
                        $this->apiEndpointUrl,
                        $payload,
                        $this->getAccessToken(true),
                        $headers,
                        $statusCode
                    ),
                    true
                );
            }
            else
            {
                throw $e;
            }
        }
        if (empty($result))
        {
            throw new DailymotionApiException('Invalid API server response');
        }
        elseif ($statusCode !== 200)
        {
            throw new DailymotionApiException("Unknown error: {$statusCode}", $statusCode);
        }
        elseif (is_array($result) && isset($result['error']))
        {
            $message = isset($result['error']['message']) ? $result['error']['message'] : null;
            $code    = isset($result['error']['code'])    ? $result['error']['code']    : null;

            if ($code === 403)
            {
                throw new DailymotionAuthRequiredException($message, $code);
            }
            else
            {
                throw new DailymotionApiException($message, $code);
            }
        }
        elseif (!isset($result['result']))
        {
            throw new DailymotionApiException("Invalid API server response: no `result` key found.");
        }
        return $result['result'];
    }
public function call ( $ resource , $ args = array ( ) ) { $ headers = array ( 'Content-Type: application/json' ) ; $ payload = json_encode ( array ( 'call' => $ resource , 'args' => $ args , ) ) ; $ statusCode = null ; try { $ result = json_decode ( $ this -> oauthRequest ( $ this -> apiEndpointUrl , $ payload , $ this -> getAccessToken ( ) , $ headers , $ statusCode ) , true ) ; } catch ( DailymotionAuthException $ e ) { if ( $ e -> error === 'invalid_token' ) { // Retry by forcing the refresh of the access token $ result = json_decode ( $ this -> oauthRequest ( $ this -> apiEndpointUrl , $ payload , $ this -> getAccessToken ( true ) , $ headers , $ statusCode ) , true ) ; } else { throw $ e ; } } if ( empty ( $ result ) ) { throw new DailymotionApiException ( 'Invalid API server response' ) ; } elseif ( $ statusCode !== 200 ) { throw new DailymotionApiException ( "Unknown error: {$statusCode}" , $ statusCode ) ; } elseif ( is_array ( $ result ) && isset ( $ result [ 'error' ] ) ) { $ message = isset ( $ result [ 'error' ] [ 'message' ] ) ? $ result [ 'error' ] [ 'message' ] : null ; $ code = isset ( $ result [ 'error' ] [ 'code' ] ) ? $ result [ 'error' ] [ 'code' ] : null ; if ( $ code === 403 ) { throw new DailymotionAuthRequiredException ( $ message , $ code ) ; } else { throw new DailymotionApiException ( $ message , $ code ) ; } } elseif ( ! isset ( $ result [ 'result' ] ) ) { throw new DailymotionApiException ( "Invalid API server response: no `result` key found." ) ; } return $ result [ 'result' ] ; }
Call a remote endpoint on the API.

@param string $resource API endpoint to call.
@param array  $args     Associative array of arguments.

@throws DailymotionApiException          If the API itself returned an error.
@throws DailymotionAuthException         If we can't authenticate the request.
@throws DailymotionAuthRequiredException If no authentication info is available.
@throws DailymotionTransportException    If a network error occurs during the request.

@return mixed Endpoint call response
Call a remote endpoint on the API .