Note that there are some explanatory texts on larger screens.

plurals
  1. PONo response from cURL function
    primarykey
    data
    text
    <p>I have written the following function, which was code I used somewhere else and modified slightly to work as a function (using $url in function parameters):</p> <pre><code>function curl2str($url) { $cURL = curl_init($url); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_CONNECTTIMEOUT, 5); $data = curl_exec($cURL); curl_close($cURL); return $data; } </code></pre> <p>I simply want a function to return a URL into a string, for a quick and easy API. The URL I am passing it is valid and works fine when I put it into a browser. I am calling it like so:</p> <p><code>&lt;?=curl2str("**valid URL here**");?&gt;</code></p> <p>For some reason it is just returning false. What am I doing wrong?</p> <p><strong>update</strong> When I put this questions URL into as <code>$url</code>, I get a response. But when I use my custom URL, which works fine in the browser, and simply display's a list of files in the directory, I get bool:false.</p> <p><strong>update 2</strong> It would seem that any domain works fine, apart from the one that I am trying to access. It just so happens that this is a root domain on the same server, I am running this script from a subdomain, but because of basedir_restrictions I cannot access a folder from the subdomain. So I wrote a little php to get the contents of the folder, and output it to the browser as a serialized array (JSON is not installed). But I cannot get a response from this root domain at all. It works fine in the browser, just not in cURL. And everything else works fine in cURL.</p> <p>:(</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload