Search code examples
phpfacebookrequire-once

require_once("facebook-sdk/facebook.php") throws a warning "failed to open stream:Permission denied"


I'm trying out the tutorials for Facebook developers. However, I can't include the Facebook PHP SDK successfully in my code. As stated, require_once("facebook_sdk/facebook.php"); throws the following error:

Warning: require_once(facebook_sdk/facebook.php) [function.require-once]: failed to
open stream: Permission denied in /opt/lampp/htdocs/awesome/plas.php on line 2

Fatal error: require_once() [function.require]: Failed opening required 'facebook_sdk/facebook.php'
(include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/awesome/plas.php on line 2

I am developing under Lucid Lynx. I tried doing chmod 777 facebook.php but the problem persists. I found this SO question but the resolution arrived at (renaming the file, as it may be conflicting with one of PHP's own) does not work for me. (Come to think of it, how will a file named facebook.php conflict with internal PHP files?!) Even if I switch to plain require, the same warnings are thrown.

Curiously, if I copy the files (facebook.php and base_facebook.php) outside of facebook_sdk and change the require_once line accordingly, the require succeeds. Any thoughts?


Solution

  • Your web server needs read access right to facebook_sdk/facebook.php. You can do it by chowning the directory to the web server user. chmod 777 is not a good practice.

    Also make sure for each of include path, facebook_sdk/facebook.php exists.