Question

So I'm trying to query an API and get a JSON object back. All works well on my local WAMP install, but when I deploy it to the server, the API query fails :( I've tried using cURL and file_get_contents(). With the same outcome. I've tried two hosts, same problem.

I looked at this question which sounds exactly like my problem. But no luck. And this other question sounds more like my problem, the problem was to do with the hosts firewall. But no detail on how he fixed it (and I can't comment yet)?

The script executes fine(on server) if the URL is say, some wikipedia page. But not the API service I'm targeting.

The API uses port 8080, so I'm suspecting that's got something to do with it, now I'm after tips on how I might be able to adress this.

Thanks.

[Update:] My Webhost says the problem is with my (quote) "codes"... So here's my test script. (Which runs fine on localhost)

<?php
$APIcall = 'http://ontoserver.csiro.au:8080/ontoserver/resources/resolve?id=392608003';

echo 'Contacting: ' . $APIcall.'<br>';
$OntoResponse = file_get_contents($APIcall, true);

echo 'Fetch data:<br>';
var_dump($OntoResponse);
?>

But when I publish it I get the following error: "Warning: file_get_contents(http://ontoserver.csiro.au:8080/ontoserver/resources/resolve?id=392608003) [function.file-get-contents]: failed to open stream: Connection timed out"

I'm stumped.. Thanks again.

Was it helpful?

Solution

The script executed without problem on my local WAMP server. My solution was to host the script on a different host (Azure), and it worked fine first time. (no special setup)

I never worked out the specific cause for this, but I'm fairly confident it's something in my shared web hosting configuration. I was trying to host my script using budget shared hosting service(Crazy Domains).

Note: Other than this, I've been happy with my host provider. But help or configuring setup to do this seems to be beyond their offering.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top