« Previous entry | Next entry » Browse > Bad code

Skip to comments (4) facebook crap
Posted by Arketa on Aug 30 2007 @ 06:16  :: 1957 unique visits

//This is what Facebook provides for PHP5 (c/p straight off their site):
<?php
require_once 'facebook.php';

$appapikey = '[your api_key]';
$appsecret = '[your secret]';
$facebook = new Facebook($appapikey, $appsecret);
$user = $facebook->require_login();

//[todo: change the following url to your callback url]
$appcallbackurl = 'http://tperry256.dreamhost.com/f8/tutorialapp/';  

//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);
}



//This is what I changed it to for PHP4:
<?php
require_once 'facebook.php';

$appapikey = 'edited out';
$appsecret = 'edited out';
$facebook = new Facebook($appapikey, $appsecret);
$user = $facebook->require_login();

//[todo: change the following url to your callback url]
$appcallbackurl = 'http://www.teamevil.org/FFXIprofile/';  

//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());
 }
} if(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);
}


/*Reverting it results in an error on line 13 in this file (13: try {), otherwise it gives a syntax error on the first blank line in facebook.php*/

4 comments posted so far
Add your own »

1. On Aug 30 2007 @ 06:25 guest wrote:

try this:

CODE: PHP
<?php
require_once 'facebook.php';

$appapikey = 'edited out';
$appsecret = 'edited out';
$facebook = new Facebook($appapikey, $appsecret);
$user = $facebook->require_login();

//[todo: change the following url to your callback url]
$appcallbackurl = 'http://www.teamevil.org/FFXIprofile/'

if (!$facebook->api_client->users_isAppAdded()) {
  $facebook->redirect($facebook->get_add_url());
}

2. On Apr 30 2008 @ 07:37 JDBurnZ wrote:

Nice little script there boddy, I will be sure to bookmark this one! :)

4. On Jan 05 2010 @ 14:57 uggbaileybutton wrote:

bailey button uggs

-ugg boots cheap

ugg boots uk

ugg classic

Add a new comment

Name:
Password: (leave empty for anonymous comment)
 
View formatting tags Comment: