I am trying to call Citi Bank's open API (https://developer.citi.com/) and this require me to scrape the screen to allow the user to login with his username and password.
This works if I simply put this URL with parameters in the browser.
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> However, when I attempt to make the same call from my PHP codes with curl, it returns status code of 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; ?> I have attempted to change my request headers so that it is just like how it would look if I had entered it as a URL in my browser.
I must have missed out something that I need to configure in curl.
Would anyone have some idea? Thank you!
redirect_uri=<my_callback_url>?<my_client_id>?