Jump to content

Recommended Posts

I am including a php file with a class called Facebook. I then immediatley call the class Facebook in my php file. It says that the class is undefined. I know that I am including the file correctly because I dont get an error message saying that the file can not be found.

Here is what I have, please help.

 

<html xmlns="http://www.w3.org/1999/xhtml"  xmlns:fb="http://www.facebook.com/2008/fbml">	<head>
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
</head>
<body>
<?
//
// this file includes FB_API_KEY and FB_SECRET constants and the ConnectDB function
// to connect to your mysql database.

$fbapikey = "xxxx";
$fbsecret = "xxxx";

$con = mysql_connect("localhost","xxx","xxx");
	mysql_select_db("xxx", $con);

//

include("facebookplatform/php/facebook.php");

// start facebook api with the codes defined above.
$fb=new Facebook($fbapikey,$fbsecret); //this is where I get the error message.
$fb_user=$fb->get_loggedin_user();

 

Here is what my included file looks like.

 

include_once 'facebookapi_php5_restlib.php';

define('FACEBOOK_API_VALIDATION_ERROR', 1);
class Facebook {
  public $api_client;
  public $api_key;
  public $secret;
  public $generate_session_secret;
  public $session_expires;

  public $fb_params;

blah blah blah alot more definitions and functions ect. 

}

 

I have no idea what is going on. I thought this was a simple  include, but php says it cant find the class which is clearly defined in the included file. By the way is for facebook Connect, if that matters.

Link to comment
https://forums.phpfreaks.com/topic/200628-php-include-going-badly/
Share on other sites

an invalid url

 

You cannot include php code using a URL. You must use a file system path.

 

A URL causes a HTTP request for the file, the same as if you browsed to it. You only receive any HTML output from that file (not to mention it takes 50-100 times longer for a HTTP request than it does reading the file through the file system.)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.