Hello Daniweb,
I was wondering how come a cURL API I made to call a function from my other website (but on the same hosting plan) no longer works.

I even tried making a test API to call in the same directory, eg...
:api.php

<?php die(json_encode("something")); ?>

:testing.php

<?php
    $url = "http://mywebsite.com/api.php";

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);

    $result = curl_exec($ch);

    if ($result === false) {
        echo "_error_".curl_error($ch);
    } else if ($result == "1") {
        echo "success";
    } else {
        echo $result;
    }

    curl_close($ch);
?>

However it's really weird, if I try that same script from testing.php but on another website that is on a different host it works fine, and vice-versa.

It just no longer works when I try to call from one site to the other which are both on my same host.

Hi, what's the result of curl_error()?

It says "Failed to connect to {DOMAIN} port 80"

Assuming the host it is trying to connect to is external to the local network, or is in another subnet, then either the internet proxy or the router (depending upon situation) will need to be reconfigured. You need to have your hosting provider deal with this.

Ok thanks, I just thought I'd see what people here on Daniweb have to say first before I contact GoDaddy.

Hi @joshl_1995

I have similar issue, did you get any solution for this?

This used to happen to me and then I contacted our sysadmin, James, and he fixed the issue. No idea what he did. All I can say is that it’s most likely a networking config setting as opposed to programming error.

However, I do vaguely recall another incident where I had to pass in a flag to bypass the SSL check when connecting to the same host.

Good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.