View Full Version : Facebook App development
sytaylor
12-15-07, 12:47 PM
Hey folks,
I'm looking into writing a few small facebook apps, basically for club promo type stuff. Im using MySQL and php. I installed the developer application fine, and I am attempting to run their Hello World sample code. Yet for some reason I cannot solve the error it throws me. It claims
Parse error: syntax error, unexpected '>' in .../facebooksytest/index.php on line 4
Does anyone have experience with Facebook app development and an idea what could be causing it?
Hey folks,
I'm looking into writing a few small facebook apps, basically for club promo type stuff. Im using MySQL and php. I installed the developer application fine, and I am attempting to run their Hello World sample code. Yet for some reason I cannot solve the error it throws me. It claims
Parse error: syntax error, unexpected '>' in .../facebooksytest/index.php on line 4
Does anyone have experience with Facebook app development and an idea what could be causing it?
hey sy,
can you post the code please?
sytaylor
12-16-07, 02:23 PM
Sure
<?php
require_once 'appinclude.php';
echo '<p>hello $user</p>';
That basically just calls appinclude which does the linking to the facebook platform.
<?php
require_once 'facebook.php';
$appapikey = 'f501a8b28b9766cb836d90fe8bae708f';
$appsecret = '8b5e7680397dd4973c5d1d6991339a80';
$facebook = new Facebook($appapikey, $appsecret);
$user = $facebook->require_login();
//[todo: change the following url to your callback url]
$appcallbackurl = 'http://www.themajesticself.com/facebooksytest/';
//catch the exception that gets thrown if the cookie has an invalid session_key in it
try {
if (!$facebook->api_client->users_isAppAdded()) {
$facebook->redirect($facebook->get_add_url());
}
} catch (Exception $ex) {
//this will clear cookies for your application and redirect them to a login prompt
$facebook->set_user(null, null);
$facebook->redirect($appcallbackurl);
}
When facebook.php is included in a download pack from facebook itself, to be installed on the webserver. Any ideas where my error is?
<?
require_once 'appinclude.php';
echo '<p>hello '.$user.'</p>';
?>
yes, obvious question... but you remembered to close the <?php tag with ?>
right?
i was writing code and i forgot a ?> tag and i got the same error.
it's due to the < symbol in the HTML and no ?> tag to close the php code.
so that's probably your problem.
t3hl33td4rg0n
12-24-07, 07:12 PM
<?
require_once 'appinclude.php';
echo '<p>hello '.$user.'</p>';
?>
Yup, if your going to use single quotes, it wont process variables, escape strings (ie: \n or \t), and the like; so you have to concatenate the variable as pross has shown.
$baz = 'zzz';
$foo = ' bar '.$baz.' r00lz '."\n";
Outputs:
bar zzz roolz
is also
$baz = "zzz";
$foo = " bar $baz roolz \n";
Outputs:
bar zzz roolz
vBulletin® v3.7.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.