Reputation: 1587
The API url is www.example.com/api/users?name=test
the curl command curl -H "Connection:keep-alive \n User-Agent: Mozilla/5.0 \n Accept:application/json" http://www.example.com/api/users?name=test
in the API controller user action, how to get the header information
public function actionUsers()
{
$this->_checkAuth();
// Get Accept type info ???
}
Upvotes: 3
Views: 4118
Reputation: 14860
Use CHttpRequest::acceptTypes
which:
Returns user browser accept types, null if not present.
CHttpRequest
is a default component and can be accessed via Yii::app()->request
:
public function actionUsers()
{
$this->_checkAuth();
$types = Yii::app()->request->acceptTypes;
}
Upvotes: 2