I can not get json from my site

(other information and details relevant to your question)
Hello. I have a problem. I am doing a REST API, and trying to get json from a site on another hosting from the site that is on your hosting, with the file_get_contents function, but I get an empty string. With curl the same. Although other sites normally return json. It does not return only the site from your hosting. Help me please.

4 Likes

okay. thank.

You are trying to fetch data from a website which is hosted on Infinityfree, or you are trying to host a website that fetches data from a REST API on a different server (not Infinityfree)? The latter is allowed. If it is the latter, please show the code.

The second option. I am trying on a different site, not infinityfree, to get json from a site on infinityfree. As I understand it, I will not succeed.

Here is the code. Website (at infinityfree):

echo json_encode(['status' => 'ok']);

Another site (not on infinityfree):

$html = file_get_contents($my_site_infonityfree);

But I do not get html

You are trying to fetch JSON data from the website on Infinityfree. This is essentially not allowed.

1 Like

Did you read the article linked to by @anon19508339. It tells you why that won’t work here.

2 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.