Facebook posting on users wall comment with permission

Hi there,

I am developing a web application for a facebook game i am developing and i am having trouble with these errors

Notice: Undefined variable: facebook in /home/willbcco/public_html/facebook/functions2.php on line 64

Notice: Trying to get property of non-object in /home/willbcco/public_html/facebook/functions2.php on line 64

Fatal error: Call to a member function users_hasAppPermission() on a non-object in /home/willbcco/public_html/facebook/functions2.php on line 64

Now i am not sure why i am getting those errors here is what i get on line 64.


			$has_permission = $facebook->api_client->users_hasAppPermission("publish_stream"); 

here is the full code i have


$u=$F_user;
			$comment="$u has attacked your army on williamsgme take back your gold buy seeking revenge on him";
			$has_permission = $facebook->api_client->users_hasAppPermission("publish_stream"); 
			if(!$has_permission)
			{
				 echo "Error Contact developers";
			}
			else
			{
				//
				echo $facebook->api_client->stream_publish($comment,$id);
				//
			}

Of course i have include the special code including facebooks api key and secret key things

its this


	require_once("php/facebook.php");
	require_once("functions.php");
	require_once("functions2.php");
	$facebook= new Facebook("APIKEY","Key");
	$fb_users=$facebook->require_login();
	$F_user='<fb:name uid="'.$fb_users.'" useyou="false" firstnameonly="false" linked="false"/>';

Why am i getting those errors,How can i get rid of those errors? Whats causing this problem any help would be good,

Thanks,William

a function has it’s own variable scope. Except for superglobals, a variable needs to be either defined inside the function, or it needs to be passed as an argument to the function. Otherwise, it simply doesn’t exist in the function.

So How should i have it then??

I recommend you pass it as a function argument.