Skip to content

Latest commit

 

History

History
34 lines (29 loc) · 665 Bytes

example-set-extra-header.md

File metadata and controls

34 lines (29 loc) · 665 Bytes

#Setting extra header

[php] <php class Person extends EActiveResource {

public static function model($className=__CLASS__)
{
    return parent::model($className);
}

public function rest()
{
$this->embedToken();

    return array(
        'site'=>'http://api.aRESTservice.com',
        'resource'=>'people',
        'contenttype'=>'application/json',
        'accepttype'=>'application/json',
        'fileextension'=>'.json',
    );
}

public function embedToken() {
	$token = user()->getState('token');
	if (!empty($token)) {
		$this->setExtraHeader(array('TOKEN: ' . $token));
	}
}   

} ?> [/php]