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:
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?
Perhaps you will need to modify your php.ini file to change
allow_url_fopen
.If you can’t modify your php.ini file or that is not an option then you have 2 other options:
fsockopen()
, or cURL.