0

I'm running apache with php 7.0 on a raspberry pi 3. When I use the curl command on the command line, it works great.

But when I use this command in my PHP code, it does nothing. Any idea what this may be?

I get a Resource id #5. I don't know what this is....

Tried the following things:

  • add 2>&1 at the end of the command
  • running the command with sudo in front
  • change privileges of www-data (not sure if that is the user that is running apache)
  • 1
    hard to say without seeing the exact code used. also what did strace show going on? – thrig Dec 3 '17 at 16:14
  • @thrig How can I see what strace is? – Refilon Dec 3 '17 at 16:19
  • @thrig I possibly get an access denied error. Any idea how to fix those? – Refilon Dec 3 '17 at 16:33
  • @Refilon: man strace. – AlexP Dec 3 '17 at 16:45
0

In PHP, any Resource id # refers to some sort of file handle, physical or otherwise. Usually there is some sort of read operation on the handle before you get your lovely data. cURL and PHP often looks similar to the following (grabbed from the docs)

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_HEADER, TRUE); 
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch); 
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
curl_close($ch);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.