/**
 * Return an associative array with keys 'key' and 'secret', containing the API
 * key and secret for the account with the specified login credentials.
 *
 * If the credentials are invalid, return an empty array.
 *
 * If the API call failed, return NULL.
 */
function jwplayer_get_api_key_secret($login, $password)
{
    require_once 'JWPlayer-api.class.php';
    // Create an API object without key and secret.
    $api = new JWPlayer_api('', '');
    $params = array('account_login' => $login, 'account_password' => $password);
    $response = $api->call('/accounts/credentials/show', $params);
    if (!$response) {
        return null;
    }
    if ('ok' != $response['status']) {
        if ('error' == $response['status'] && 'NotFound' == $response['code']) {
            return array();
        }
        return null;
    }
    // No errors.
    return array('key' => $response['account']['key'], 'secret' => $response['account']['secret']);
}
Example #2
0
/**
 * Verify the API key and secret that the user has given, by making a call to
 * the API.
 *
 * If the credentials are invalid, return false.
 *
 * If the API call failed, return NULL.
 */
function jwplayer_login_verify_api_key_secret($key, $secret)
{
    // require_once 'include/jwplayer-api.class.php';
    // Create an API object with the provided key and secret.
    $api = new JWPlayer_api($key, $secret);
    $response = $api->call('/accounts/show', $params);
    return jwplayer_api_response_ok($response);
}
Example #3
-1
/**
 * Verify the API key and secret that the user has given, by making a call to
 * the API.
 *
 * If the credentials are invalid, return false.
 *
 * If the API call failed, return NULL.
 */
function jwplayer_login_verify_api_key_secret($key, $secret)
{
    // Create an API object with the provided key and secret.
    $api = new JWPlayer_api($key, $secret);
    $response = $api->call('/accounts/show');
    return jwplayer_api_response_ok($response);
}