Example #1
0
	<fb:create-button href="index.php?action=add">Create a Suggestion</fb:create-button>
</fb:dashboard>
<?php 
// Say hi to the user, but let's use an fbml tag, just as another example of using fbml
// instead of html
echo '<fb:explanation><fb:message>Suggestions Demo Application</fb:message>Welcome ' . $name[0]['first_name'] . '</fb:explanation>';
// Control what template we load
// Templates are just php files with fbml/html in them.  We use php so we can perform variable substitution
// loop through data, etc...  Normal template language stuff without the template language!
if (isset($_REQUEST['action'])) {
    $action = $_REQUEST['action'];
    // Add == show the add page
    if ($action == 'add') {
        $friends = $rest->delegate->friends_get();
        $friends[] = $userid;
        $topics = SuggestionUtils::getTopics($friends);
        include_once 'add.php';
    } else {
        if ($action == 'add_suggestion') {
            if ((isset($_REQUEST['existingtopic']) || isset($_REQUEST['newtopic'])) && isset($_REQUEST['suggestion'])) {
                $ownerid = 0;
                $topic = '';
                $suggestion = $_REQUEST['suggestion'];
                // Topics are messed up for new topics
                if (isset($_REQUEST['existingtopic']) && $_REQUEST['existingtopic'] != 'none') {
                    $str = $_REQUEST['existingtopic'];
                    // comes in the form ownerid:toic
                    $pos = strpos($str, ':');
                    if ($pos) {
                        $ownerid = substr($str, 0, $pos);
                        $topic = substr($str, $pos + 1, strlen($str));
Example #2
0
	<fb:create-button href="index.php?action=add">Create a Suggestion</fb:create-button>
</fb:dashboard>
<?php 
// Say hi to the user, but let's use an fbml tag, just as another example of using fbml
// instead of html
echo '<fb:explanation><fb:message>Suggestions Demo Application</fb:message>Welcome ' . $name[0]['first_name'] . '</fb:explanation>';
// Control what template we load
// Templates are just php files with fbml/html in them.  We use php so we can perform variable substitution
// loop through data, etc...  Normal template language stuff without the template language!
if (isset($_REQUEST['action'])) {
    $action = $_REQUEST['action'];
    error_log("Action={$action}");
    // Add == show the add page
    if ($action == 'add') {
        $uids = $rest->delegate->friends_get();
        $topics = SuggestionUtils::getTopics($uids);
        include_once 'add.php';
    } else {
        if ($action == 'add_suggestion') {
            if ((isset($_REQUEST['existingtopic']) || isset($_REQUEST['newtopic'])) && isset($_REQUEST['suggestion'])) {
                $ownerid = 0;
                $topic = '';
                $suggestion = $_REQUEST['suggestion'];
                // Topics are messed up for new topics
                if (isset($_REQUEST['existingtopic']) && $_REQUEST['existingtopic'] != 'none') {
                    $str = $_REQUEST['existingtopic'];
                    // comes in the form ownerid:topic
                    $pos = strpos($str, ':');
                    if ($pos) {
                        $ownerid = substr($str, 0, $pos);
                        $topic = substr($str, $pos + 1, strlen($str));