0
我正在使用以下API調用使用json格式,但我沒有以任何格式獲取輸出。 我想知道的是,我可以如何使用javacript設置代理代碼,以便我可以從跨服務器(另一臺服務器)獲取數據。 是否有任何其他可能性來接收/顯示來自外域的數據? iFrames遵循相同的政策? 這裏是我的API網址: api.wego.com/flights/api/k/2/searches?api_key=your_secret_api_key & ts_code = your_secret_ts_codeJSON POST請求 - JSON數據,如何使用代理請求在跨服務器上使用JSON格式的數據發佈POST請求
,我想通過下面的參數是: { 「旅行」 : { 「departure_code」: 「SIN」 「arrival_code」: 「HKG」, 「outbound_date」: 「2013年10月14日」, 「inbound_date」: 「2013年10月21日」 } ], 「adults_count」:1 }
,我就是用這個下面的代碼:{}`在
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_URL, 'http://api.wego.com/flights/api/k/2/searches?api_key=xxxxxxxxx&ts_code=xxxxx');
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: application/json','Accept: application/json'));
$data =
"trips": [
{
"departure_code": "SIN",
"arrival_code": "HKG",
"outbound_date": "2013-10-14",
"inbound_date": "2013-10-21"
}
],
"adults_count": 1;
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$result=curl_exec($ch);
var_dump($result);
感謝
想念''$ data' – aaron
我添加了這個,但仍然它不工作.. – user2854487