php - Trying to access url that returns json results in connection reset by peer error

397

My php web app is trying to access another URL on the same site that returns a json payload. My web app is using file_get_contents() on the url that returns the json and then does something with it.

I have tried using curl instead of file_get_contents, but i get the same errors which are:

A PHP Error was encountered
Severity: Notice
Message: file_get_contents(): send of 24 bytes failed with errno=104 Connection reset by peer
Filename: xxxxxx.php
Line Number: 46

And

A PHP Error was encountered
Severity: Notice
Message: file_get_contents(): send of 2 bytes failed with errno=32 Broken pipe
Filename: xxxx.php
Line Number: 46

Now, this worked on the previous server the web app was hosted on i'm told and this is now on some shared hosting.

So, to recap, when you visit the url http://example.com/getjson it runs some php that does:

$foo = file_get_contents('http://example.com/twitter.json/?user_id=xxxxxx&count=500&include_rts=1&page=1&include_entities=5');

If i visit http://example.com/twitter.json/?user_id=xxxxxx&count=500&include_rts=1&page=1&include_entities=5 in my browser i see the json, if i try and get it with php, i get the errors above.

I just can't think what to try next!

Any help gratefully received!

People are also looking for solutions to the problem: php - WordPress : error while fetching post

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.