0

I'm trying to use the G2A search api (got it from web sniffing). This is the url: https://www.g2a.com/new/api/v2/products/filter/?query=PSN&sort=preorder&wholesale=false. When I go there in my browser it just normally shows me a ton of results. While when I use PHP, I get "Access Denied". Here is the code that I'm using right now:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://www.g2a.com/new/api/v2/products/filter/?query=PSN&sort=preorder&wholesale=false");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = [
    'Upgrade-Insecure-Requests: 1',
    'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36',
    'Sec-Fetch-User: ?1',
    'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
    'Sec-Fetch-Site: none',
    'Sec-Fetch-Mode: navigate',
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$res = curl_exec($ch);
curl_close($ch);

When I do echo $res. It returns the "access denied" saying I have no access. Any way around this? Thanks for your time,

EDIT: When I use Edge (total clean browser, never use it), it just normally shows the results. The PHP and the browsers are both on the same machine, so it's not an IP range block.

RBLX CLICK
  • 33
  • 2
  • Maybe it's something to do with https - https://stackoverflow.com/questions/4372710/php-curl-https – Nigel Ren Jan 13 '20 at 16:15
  • @NigelRen it doesn't, D: – RBLX CLICK Jan 13 '20 at 16:17
  • You need to login via api and get the apikey more info here https://www.g2a.com/integration-api/documentation/export/#api-Orders-AddOrder – ErDiablo Jan 13 '20 at 16:18
  • @ErDiablo bit it also works just in browser without API key, or in a total clean browser (as stated in my question) where I openeded Edge which I have never visited G2A with ever, and it just normally worked. – RBLX CLICK Jan 13 '20 at 16:19

0 Answers0