使用$ http和php / Yii进行角度/离子身份验证

I am trying to authenticate to a Yii API (Yii Version 1.1.15) using an ionic / angular app, and can't get headers within the PHP page.

The angular code is:

 $http({
        headers: {'X_ASCCPE_USERNAME': username,'X_ASCCPE_PASSWORD': password},
        url: 'http://example.com/index.php/',            
        params: {r: 'api/list',model: 'users',callback:'JSON_CALLBACK'}
    })

and the PHP code is:

    $username = $_SERVER['HTTP_X_'.self::APPLICATION_ID.'_USERNAME'];
    $password = $_SERVER['HTTP_X_'.self::APPLICATION_ID.'_PASSWORD'];

but the username and password are not set in $_SERVER['HTTP_X_ASCCPE_USERNAME'] and
$_SERVER['HTTP_X_ASCCPE_PASSWORD'].

The only place I see these is HTTP_ACCESS_CONTROL_REQUEST_HEADERS==>accept, x_asccpe_password, x_asccpe_username

How do I pass these from angular ($http) to PHP / Yii ?

You are prepending HTTP_ to the header. But it is not needed.

Change your php code to:

$username = $_SERVER['X_'.self::APPLICATION_ID.'_USERNAME'];
$password = $_SERVER['X_'.self::APPLICATION_ID.'_PASSWORD'];