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 ???
}
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With