API issue with Curl Request

Hi,

I am having an issue while connecting to SuiteCRM 7.7 through SugarAPI. See the attached image of my code, when I run, it says ā€˜couldnā€™t connect to hostā€™.
I can access the URL from browser and the username & password are also correct. the same code works fine on localhost but on live system it fails.

Please help me to fix this.

thanks

Could this be a firewall or network restriction issue?

Yes, I think so, I tried contacting web hosting support to see this, they said its your software issue. Can you explain how to resolve this from server or from coding site.

thanks

Create a page on the root of your web host with the following code:

$ch = curl_init("http://google.com");    // initialize curl handle
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    $data = curl_exec($ch);
    print($data);

And then run this page in your browser. If you are not seeing the Google home page, it is an issue with your host.

1 Like

Hi digitalmcgrath,

thank you for helping me, I ran the code you suggested and it worked fine. But in the same file where I access google home page, when I try to access the CRM URL (any version of API like V4 or V4_1 or V3 etc) it says the same error message ā€˜couldnā€™t connect to hostā€™. From browser I can access those API urls directory.

I tried to contact web-hosting they said they will try to track the issue but the possible reason is our package is shared hosting and that applies some restrictions.

thanks