SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2010
    Posts
    70
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    PHP with some FBML issue

    Hey. I will post my code and try to explain the issue i am having.

    Code:
    <?php
    define('FB_ROOT', "http://apps.facebook.com/tester/index.php/");
    define('HTML_ROOT', "http://www.tester.com/facebook/");
    define('APP_ID', "xxxxxxxxxxxxx");
    define('APP_SECRET', "xxxxxxxxxxxxxxxxxxxxxxxxx");
    
    function fb_root($url="") {
    	return FB_ROOT . $url;
    }
    
    function html_root($url="") {
    	return HTML_ROOT . $url;
    }
    
    function redirectToCanvas() {
    	header('Location: '.fb_root());
    }
    ?>
    
    <?php
    
    require 'facebook.php';
    
    
    $facebook = new Facebook(array(
      'appId'  => APP_ID,
      'secret' => APP_SECRET,
      'cookie' => true
    ));
    
    $debug = false;
    
    if ($facebook->getSession() && $debug == false) {
    
    	// User is logged in and authorized, let's party.
    
    	// Get friends list of current user
    	$call = $facebook->api('/me/friends');
    	$friends_list = $call['data'];
    	
    	// Get user information of current user
    	$call = $facebook->api('/me');
    	$my_info = $call;
    	
    	$user = $facebook->getUser();
    	
    ?>
    
    <h1>tester.com</h1>
    <h3>By: <a href="http://www.tester.com?">tester.com</a> - visit us today!</h3>
    <hr/>
    <p>Free personalised animated e-cards for all occassions</p>
    
    <?php
    	
    } else {
    
    	$params = array(
    		'fbconnect'=>0,
    		'canvas'=>1,
    		'req_perms'=>'',
    		'next'=>fb_root(),
    		'cancel_url'=>fb_root()
    	);
    	
    	$redirect = $facebook->getLoginUrl($params);
    	
    	echo '<fb:redirect url="' . $redirect . '">';
    	
    }
    
    ?>
    
    <fb:swf swfbgcolor="ffffff"  swfsrc='http://www.tester.com/facebook/tester/Bcard2.swf' width='380' height='250' />
    
    <form method="post" onsubmit="return validateFormOnSubmit(this)" action="birthdayPreview.php">
        <p>Receivers Name<a> 
        <input type="text" name="receiver" size="30" maxlength="35" /></a></p>
        <p>Senders Name<a> 
        <input type="text" name="sender" size="30" maxlength="35" /></a></p>
        <p><input type="submit" value="Preview"/></p>
    </form>
    
    <fb:fbml>
    <fb:request-form
    action="index.php" 
    method="POST" 
    invite="true" 
    type="tester" 
    content="Send an E-Card to your friends. <?php echo htmlentities("<fb:req-choice url=\"http://apps.facebook.com/tester/\" label=\"Authorize My Application\"") ?>" > 
    <fb:multi-friend-selector showborder="false" actiontext="Invite your friends to use tester."> 
    </fb:request-form>
    </fb:fbml>
                
    <fb:comments xid="graphapi_comments" canpost="true" candelete="false" returnurl="<?=fb_root()?>">
    <fb:title>Talk about this application</fb:title>
    </fb:comments>
    
    <center><img src="http://www.e-zeeinternet.com/count.php?page=444454&style=default&nbdigits=7" alt="Free Hit Counter" border="0" ></center>
    I dont know if anyone knows much FBML, but hopefully this is more a php issue. Basically, as it stands, in my form I have the action set to call up birthdayPreview.php. However, whenever submit is pushed, it seems to call up index.php. Can anyone see any reason why this might be?

    cheers

  2. #2
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,271
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    I don't know either FB or PHP but... your form action is correct. Alone, this form would call birthdayPreview.php (unless the server had a really stupid redirect like ^(.*)$ index.php/$1 [L] or something (who knows?).

    But, after your form, you have this:
    Code:
    </form>
    
    <fb:fbml>
    <fb:request-form
    action="index.php" 
    method="POST" 
    ...
    I can't read what that's doing, but doesn't it override your form's own action?

    As a side note, why are there anchors wrapping your inputs? And where are the form labels?

  3. #3
    SitePoint Wizard frank1's Avatar
    Join Date
    Oct 2005
    Posts
    1,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup that action does make the difference there
    i have not gone through your whole code but
    action
    string
    The place where a user gets redirected after submitting the form through the fb:request-form-submit button or when they click Skip this Step. By default the user is directed to http://apps.facebook.com/yourapp/null. ''Note: This default behavior may not be preserved.''
    http://developers.facebook.com/docs/...l/request-form

    thanks

  4. #4
    SitePoint Member
    Join Date
    May 2009
    Location
    Norfolk, VA
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    FBML has been deprecated.

    not very helpful, but fyi yo


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •