API call throws Error 403 Forbidden

Avatar image for deactivated-5b17b9d9a59ea
deactivated-5b17b9d9a59ea

4

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

Hey guys and @jslack,

I'm having some troubles using your API.
I've signed up for an API key, tested an API call in my browser and got a successful response.
Then I've implemented it into my project which is a PHP project.
But when I try to get the response via PHP it fails. It always throws a 403 error, forbidden.

So, is there a restriction I don't know of? Any IP whitelisting options or request methods that are restricted?
I'm trying to get the JSON response with "file_get_contents". I've also tried getting it with "fopen" or CURL.
You can see the error message below (Token replaced).

Warning: file_get_contents(http://www.giantbomb.com/api/game/3030-12572/?api_key=<TOKEN>&format=json&field_list=name,aliases): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in /home/.sites/19/site2864341/web/cms/ext/quiz/pi1/get_giantbomb_data.php on line 18

If I call the API by opening the URL in my browser, I get a wonderful response:

{"error":"OK","limit":1,"offset":0,"number_of_page_results":1,"number_of_total_results":1,"status_code":1,"results":{"aliases":"OOT\nLOZ:OOT\nZelda no Densetsu: Toki no Ocarina\n\u30bc\u30eb\u30c0\u306e\u4f1d\u8aac \u6642\u306e\u30aa\u30ab\u30ea\u30ca\nZelda 64","name":"The Legend of Zelda: Ocarina of Time"},"version":"1.0"}

Any help on that? :)
I really can't explain what's going on.

Thanks a million in advance!

Avatar image for laika
laika

148

Forum Posts

1

Wiki Points

0

Followers

Reviews: 0

User Lists: 1

Are you making these requests (browser and PHP) on the same machine/IP?

Avatar image for deactivated-5b17b9d9a59ea
deactivated-5b17b9d9a59ea

4

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

@laika: nope. The browser copy & paste request ist done in a browser on my MacBook. The request from the PHP script is executed on my server. So they come from different IP addresses and machines.

Avatar image for laika
laika

148

Forum Posts

1

Wiki Points

0

Followers

Reviews: 0

User Lists: 1

It's possible that your server's IP address is in a blocked range (due to abusive behavior). PM us with the IP and we can take a look.

Avatar image for rick
rick

506

Forum Posts

33

Wiki Points

0

Followers

Reviews: 1

User Lists: 1

#5  Edited By rick

If anyone is getting this recently you're probably coming from a commercial web host. They're all blocked now by default. Send the CIDR for your server(s) to ipbans (at) gamespot.com to get whitelisted.

Avatar image for mustardbomb
MustardBomb

3

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#6  Edited By MustardBomb

@edgework: I'm having the same problem, except i'm issuing requests from my project (javascript) and from my browser using the same machine. everything works fine in the browser, but i'm getting a nasty 403 when requesting via javascript.

Everything was fine from the js a few days ago when i first tested the code - the problem only started today (or at least, today is when i first noticed it). Thoughts on what might be going on?

Heres an example url thats causing problems (but working fine in browser), subbing out the key of course: http://www.giantbomb.com/api/search/?api_key=<APIKEY>&query=Papers,%20Please&format=json

UPDATE: more detail on the error below. I'm not using a wordpress scraper - just issuing GET requests using the Request-promise http client (https://www.npmjs.com/package/request-promise)

<h1>Wordpress RSS Reader / Scraper Blocked</h1>

<p>

Sorry we do not allow WordPress plugins to scrape our site. They tend to be used maliciously to steal our content. We do not allow scraping of any kind.

You can load our RSS feeds using any other reader but you may not download our content.

<a href='/feeds'>Click here more information on our feeds</a>

</p>

<p>

Or you're running some other sketchy bot that we don't allow. Don't go trying to impersonate any other bot now, that WILL get you permanently banned!

</p>

<p>

Or.... maybe you're running an LG Podcast player written by a 10 year old. Either way, Please stop doing that.

</p>

Avatar image for rick
rick

506

Forum Posts

33

Wiki Points

0

Followers

Reviews: 1

User Lists: 1

#7  Edited By rick

@mustardbomb: You need to send a user agent that describes who you are. Generic UAs like curl, wget, Java, PHP etc. are now ignored as are empty UAs. We need to know whose bots are knocking at the door. Set your UA to something unique like "MustardBombsAwesomeBot" and you'll be fine.

Avatar image for mustardbomb
MustardBomb

3

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

@edgework: Thanks for the quick response. That did it!

Avatar image for rammone4
rammone4

18

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

@edgework I'm experiencing the same issue with my site http://parallel.team just followed your instructions. Hopefully that should take care of it. Thanks for the info

Avatar image for totranquilo
totranquilo

1

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#11  Edited By totranquilo

@edgework : Warning: file_get_contents(http://www.giantbomb.com/api/games/?

I am having the same problem, how can I solve

-------------------------------

$vdata = file_get_contents('http://www.giantbomb.com/api/games/?api_key='.$giantbomb_key.'&platforms='.$platform_id.'&sort=date_added:desc&field_list=date_added,deck,id,image,name,platforms&limit=10&offset='.$offset.'0&format=json');

$vresponse = json_decode($vdata);

if ($vresponse->results==NULL){

echo '';

Avatar image for rick
rick

506

Forum Posts

33

Wiki Points

0

Followers

Reviews: 1

User Lists: 1

@totranquilo: http://lmgtfy.com/?q=file_get_contents+user+agent

Avatar image for sthyb99
sthyb99

1

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

@rick: how do you do¿?¿?

Avatar image for naraku4563
Naraku4563

1

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#15  Edited By Naraku4563

Hey! I'm all of a sudden getting a 403 error when I try to send my xhr Request. I'm currently using the api in a project for school along with vue and I'm still learning the ropes while testing. How can i fix this?