\yii\filters\Cors::className(),
'cors' => [ // restrict access to
'Access-Control-Request-Method' => ['*'], // Allow only POST and PUT methods
'Access-Control-Request-Headers' => ['*'], // Allow only headers 'X-Wsse'
'Access-Control-Allow-Credentials' => true, // Allow OPTIONS caching
'Access-Control-Max-Age' => 3600, // Allow the X-Pagination-Current-Page header to be exposed to the browser.
'Access-Control-Expose-Headers' => ['X-Pagination-Current-Page'],
],
];
//配置ContentNegotiator支持JSON和XML响应格式
/*$behaviors['contentNegotiator'] = [
'class' => ContentNegotiator::className(), 'formats' => [
'application/xml' => Response::FORMAT_XML
]
];*/
$behaviors['access'] = [
'class' => AccessControl::className(),
'rules' => [
[
'ips' => ['119.254.26.*', //去哪儿IP访问白名单
'127.0.0.1','106.14.56.77','180.168.4.58' //蜘蛛及本地IP访问白名单
], 'allow' => true,
],
],
];
return $behaviors;
}
/**
* Author:Steven
* Desc:酒店静态数据接口 Qunar会定期通过此接口获取代理商可以售卖的酒店列表。酒店静态属性主要包括:酒店ID、酒店名称、城市、地址、电话
*/
public function actiongetFullHotelInfo()
{
//获取所有在阿里飞猪上售卖的房型列表
$res = ChannelHotel::find()
->joinWith('operaHotel b', false)
->leftJoin('base_area c', 'b.AREA_ID=c.ID and c.CANCEL_FLAG=0')
->select(['a.ChannelHotelId', 'b.*', 'c.AREA_NAME'])
->where(['a.ChannelId' => 1, 'b.CANCEL_FLAG' => 0, 'c.CANCEL_FLAG' => 0])
->from('channel_hotel_relation a')->asArray()->all();
/*return \Yii::createObject([
'class' => 'yii\web\Response',
'format' => \yii\web\Response::FORMAT_XML,
'formatters' => [
\yii\web\Response::FORMAT_XML => [
'class' => 'yii\web\XmlResponseFormatter',
'rootTag' => 'list', //根节点
'itemTag' => 'hotel', //单元
],
],
'data' => [ //要输出的数据
['remarks'=>''],
],
]);*/
$xml = "";
$xml = "";
foreach ($res as $item) {
$xml .= "";
}
$xml .= "
";
$xml=" xml version = \"1.0\" encoding = \"UTF-8\"?>\n
";
echo $xml;
}
}
?>