WordPress plugin cannot cURL or file_get_contents for URLs on the same site

I have a WordPress site that supports IFRAME codes for certain content. I want for other sites to be able to request an embed code for a given post with a query var.

Example:

Read More
echo file_get_contents("mysite.com/?get_embed_code=123");

Result:

<iframe src="mysite.com/permalink-to-post/123"></iframe>

It works on other people’s sites, but not on my own. Another site can use file_get_contents() to request a response from mysite.com, but mysite.com cannot, as it runs into a looping error.

  • With cURL it crashes the server.
  • With file_get_contents it waits and then returns "unable to establish database connection".

Any ideas on ways to approach this that work on my own server as well as on others?

Related posts

Leave a Reply

1 comment