I’m trying to embed a PDF document viewer on my site, and to do so in a secure fashion entails retrieving the data from a remote site. To do that, the sample code provided by the PDF viewer company uses file_get_contents. However, whenever I have the file_get_contents statement, with any URL, my page simply doesn’t load at all. I do have PHP on (it’s used to generate the entire page this is on, successfully in every other way), and set to Output, and as far as I can tell, fopen() wrappers are turned on. Initially, I’d thought the problem might be related to the URL not being URL-encoded, but when I URL encode it, the file_get_contents command does nothing (which enables the page to load, but without retrieving the necessary data).
Any ideas why file_get_open is failing? Thanks!
cheers… -Adam
PS: Here’s the code snippet:
{!-- This code encrypts all the data in the transaction so the URL is not visible. --}
$cloudconnectkey = "foobar";
$documentLocation = "https://www.takecontrolbooks.com/pdf/" . $read_online;
$urlstring = "http://connect.ajaxdocumentviewer.com/encrypt/?key=" . $cloudconnectkey . "&document;=" . $documentLocation . "&viewerheight=1050&viewerwidth=900&cache=No&printButton=No&saveButton=No&logoimage=http://www.takecontrolbooks.com/tc-graphics/tc_web_title_ebooks_v02.gif&quality=high&ssl=No";
{!-- If the line below is enabled, the page tries to load until it times out. If I use any URL in place of $urlstring, the page will not load; if I use any non-URL, the page loads but $encryptedStr is blank. --}
$encryptedStr = file_get_contents($urlstring);
$embedLink = "http://connect.ajaxdocumentviewer.com/?key=" . $cloudconnectkey . "&encrypt=1&encrypttext;=" . $encryptedStr;
$cloud_connect_display_ssl = "<a href="http://">{title}</a>";
echo $cloud_connect_display_ssl . "
";
{!-- The line below shows that urlstring is being generated correctly. --}
echo "<strong>urlstring</strong>: " . $urlstring . "
";
{!-- The line below shows that when $encryptedStr is generated via file_get_open pointing at a non-URL, $encryptedStr remains blank. --}
echo "<strong>encryptedStr</strong>: " . $encryptedStr . "
";
{!-- The line below shows that $embedLink is generated correctly, short of $encryptedStr. --}
echo "<strong>embedLink</strong>: " . $embedLink . "
";
{!-- Tried the line below as a test; if it's enabled, the page won't load either. --}
{!-- echo "<strong>Test</strong>: " . file_get_contents ('http://www.tidbits.com/') . "
"; --}