私はCiti Bankの公開API(https://developer.citi.com/)に電話をかけようとしていますが、ユーザーが自分のユーザー名とパスワードでログインできるように画面をスクラップする必要があります。ウェブサイトをスクラップするためのPHPを使用していない
これは、ブラウザにこのURLをパラメータとともに入力するだけで動作します。私はカールと私のPHPコードから同じ呼び出しを試みるとき
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>
しかし、それは私はそれがあるように私のリクエストヘッダを変更しようとしてきた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として入力したかどうかのように見えます。
私はカールで設定する必要があるものを逃しているに違いありません。
誰もが考えているだろうか?ありがとうございました!
'redirect_uri = 'とは何ですか? –
madalinivascu
と ''? –
madalinivascu
私のコールバックURLです。 Authorize apiは、私がここで述べたもの、例えばhttp://www.myurl.com/bank/hello.phpを呼び出します。 –