nV News Forums

 
 

nV News Forums (http://www.nvnews.net/vbulletin/index.php)
-   Software Development (http://www.nvnews.net/vbulletin/forumdisplay.php?f=53)
-   -   Facebook App development (http://www.nvnews.net/vbulletin/showthread.php?t=104352)

sytaylor 12-15-07 11:47 AM

Facebook App development
 
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

Code:

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?

ViN86 12-16-07 12:21 AM

Re: Facebook App development
 
Quote:

Originally Posted by sytaylor
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

Code:

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 01:23 PM

Re: Facebook App development
 
Sure

Code:

<?php
require_once 'appinclude.php';

echo '<p>hello $user</p>';

That basically just calls appinclude which does the linking to the facebook platform.

Code:

<?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?

pross 12-16-07 01:50 PM

Re: Facebook App development
 
Code:

<?
require_once 'appinclude.php';

echo '<p>hello '.$user.'</p>';
?>


ViN86 12-16-07 05:26 PM

Re: Facebook App development
 
yes, obvious question... but you remembered to close the <?php tag with ?>

right?

ViN86 12-16-07 07:37 PM

Re: Facebook App development
 
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 06:12 PM

Re: Facebook App development
 
Quote:

Originally Posted by pross
Code:

<?
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.

Code:

$baz = 'zzz';
$foo = ' bar '.$baz.' r00lz '."\n";

Outputs:
Code:

bar zzz roolz
is also
Code:

$baz = "zzz";
$foo = " bar $baz roolz \n";

Outputs:
Code:

bar zzz roolz


All times are GMT -5. The time now is 10:33 PM.

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.