我正在嘗試撥打花旗銀行的開放式API(https://developer.citi.com/),這需要我刮擦屏幕以允許用戶使用其用戶名和密碼登錄。使用PHP捲起網頁無法正常工作
如果我只是把這個URL與參數放在瀏覽器中,
https://sandbox.apihub.citi.com/gcb/api/authCode/oauth2/authorize?response_type=code&client_id=<my_client_id>&scope=pay_with_points&countryCode=SG&businessCode=GCB&locale=en_SG&state=12093&redirect_uri=<my_callback>
然而,當我試圖從我的,捲曲的PHP代碼進行相同的調用,它返回的503
<?php
$header = array();
$header[] = 'Upgrade-Insecure-Requests: 1';
$header[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8';
$header[] = 'Accept-Encoding: gzip, deflate, br';
$header[] = 'Accept-Language: en-US,en;q=0.8,ja;q=0.6,zh-CN;q=0.4,zh;q=0.2,zh-TW;q=0.2,th;q=0.2';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://sandbox.apihub.citi.com/gcb/api/authCode/oauth2/authorize?response_type=code&client_id=<my_client_id>=pay_with_points&countryCode=SG&businessCode=GCB&locale=en_SG&state=12093&redirect_uri=<my_callback_url>');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36');
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close ($ch);
echo $result;
?>
我試圖改變我的請求頭,使其狀態碼就像我在瀏覽器中輸入URL時的樣子。
我一定錯過了我需要在curl中配置的東西。
會有人有一些想法嗎?謝謝!
whats with'redirect_uri ='? –
madalinivascu
和''? –
madalinivascu
這是我的回撥網址。授權API將回調我在這裏說的,例如http://www.myurl.com/bank/hello.php。 –