1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Facebook app help

Discussion in 'FaceBook' started by whothefisalex, Jan 14, 2012.

  1. whothefisalex

    whothefisalex Junior Member

    Joined:
    Nov 24, 2011
    Messages:
    178
    Likes Received:
    30
    ok i need somebody who is good with facebook apps for some advice.

    i have made a app using the firstorm 2 guide, the app works fine, the allow permision pop-up works, but here is the problem...

    the app dose not post on the users wall. (it should leave a post advertising the app to friends on a users wall")

    also when i check the database in phpmyadmin it dose not seem to be capturing the email adress and detaisl of the user. so i think the error maybe related to the database?

    im not too sure what could have gone wrong? but when i use the debug tool in facebook tools section the only problem that comes up is this...

    Open Graph Warnings That Should Be Fixed


    Extraneous Property:Objects of this type do not allow properties named og:site_url


    i would be very grateful if somebody could point me in the right direction
     
  2. whothefisalex

    whothefisalex Junior Member

    Joined:
    Nov 24, 2011
    Messages:
    178
    Likes Received:
    30
    did facebook change somthing, since the firestorm course was made? cos i gone through all the steps like a million times and done everything like for like
     
  3. CoolAdvisor

    CoolAdvisor Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 24, 2008
    Messages:
    976
    Likes Received:
    360
    Do you request special permissions?
    Also, the user also maybe blocked posting by others on his wall.
    You also need to store special code, unique to the user id and your app.
     
  4. CoolAdvisor

    CoolAdvisor Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 24, 2008
    Messages:
    976
    Likes Received:
    360
    it's hard to tell without the code
     
  5. whothefisalex

    whothefisalex Junior Member

    Joined:
    Nov 24, 2011
    Messages:
    178
    Likes Received:
    30
    thanks for your reply.

    I request the special permissions i need.

    The wall posts arn't blocked because i tested this with a couple of my own accounts.

    im not sure how what this means about storing the permissions unique to the user, im pretty sure this is handled by the script i uploaded
     
  6. whothefisalex

    whothefisalex Junior Member

    Joined:
    Nov 24, 2011
    Messages:
    178
    Likes Received:
    30
    Code:
    // FB App System, version 2.0
    //copyright 2010-2011, FBappSystem.com
    //For Personal Use Only:
    //You may install it on your domain only.
    //You MAY NOT install it on pages and domains not owned by you, or pass it to others for their use.
    //Unauthorized duplication, distribution or use are STRICTLY FORBIDDEN and are punishable by U.S. and international law.
    window.fbAsyncInit = function() {
        FB.init({ appId: appid, status: true, cookie: true, xfbml: true });
        FB.getLoginStatus(function(response) {
            if (response.session) {
              var access_token = response.session.access_token;
                FB.api(
                                                {
                                                    method: 'fql.query',
                                                    query: 'SELECT uid,pic_big,name,email,birthday_date,sex,first_name,last_name,current_location FROM user WHERE uid=' + FB.getSession().uid
                                                },
                                 function(response) {
                                    var user = response[0];
                                        var city = "";
                                        var state = "";
                                        var country = "";
                                     if (user.current_location != null) {
                                          city = user.current_location['city'];
                                          state = user.current_location['state'];
                                          country = user.current_location['country'];
                                     }
                                     //setTimeout("alert('hello')",1250);
                                       CheckUser(user.uid, user.name, user.email, user.sex,  user.birthday_date, city, state, country,access_token);
                                     // postwallmessage() ;
                                 });     // A user has logged in, and a new cookie has been saved
            }
        });
    
    };
    (function() {
        var e = document.createElement('script');
        e.type = 'text/javascript';
        e.src = document.location.protocol +
                        '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
    } ());
     
    function CheckUser(facebookid,name,email,sex,bdate,city,state,country,access_token)
       {
                         // alert(name); alert(name);
           $.ajax({
               type: "POST",
               url: websiteurl+"ajax.php",
                         async:false,
               data: "fid=" + facebookid + "&name=" + name + "&email=" + email + "&sex=" + sex  + "&bdate=" + bdate + "&city=" + city + "&state=" + state + "&country=" + country+"&accesstoken="+access_token,
               success: function(msg) {
                             //   alert(msg);
     
    
               }
                        ,
               error: function(xmlHttpRequest, textStatus, errorThrown) {
     
               }
           });
       }
    
    ///This function post the axiom to user wall
    ////This function is  used to post to the user wall
                function PostFeeds() {
             var params = {};
             params['message'] = '';
             params['name'] = "Social Profit Formula Bonus!";
             params['description'] = "Purchase Social Profit Formula through my link and receive my never before released software 'The FB App System' an iPad2 [URL]http://FBappSystem.com/sfp[/URL]";
             params['link'] = "[URL]http://apps.facebook.com/spfbonus/default.php[/URL]";
             params['picture'] = "[URL]http://apps.facebook.com/spfbonus/logo.jpg[/URL]";
             params['caption'] = "FBappSystem.com/sfp";
             FB.api('/me/feed', 'post', params, function(response) {
                 if (!response || response.error) {
                  //alert(dump(response));
                 } else {
                       // alert(dump(response));
                 }
             });
         }
    
         function dump(arr, level) {
        var dumped_text = "";
        if (!level) level = 0;
        //The padding given at the beginning of the line.
        var level_padding = "";
        for (var j = 0; j < level + 1; j++) level_padding += "    ";
        if (typeof (arr) == 'object') { //Array/Hashes/Objects
            for (var item in arr) {
                var value = arr[item];
                if (typeof (value) == 'object') { //If it is an array,
                    dumped_text += level_padding + "'" + item + "' ...\n";
                    dumped_text += dump(value, level + 1);
                } else {
                    dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
                }
            }
        } else { //Stings/Chars/Numbers etc.
            dumped_text = "===>" + arr + "<===(" + typeof (arr) + ")";
        }
        return dumped_text;
    }
    i assume this is the code you need to see?
     
  7. whothefisalex

    whothefisalex Junior Member

    Joined:
    Nov 24, 2011
    Messages:
    178
    Likes Received:
    30
    i guess the problem has to be somthing to do with my database not interacting with facebook because the only 2 features that dont work is wall posting and collecting the users e-mail.

    and they are the two things handled by my php database.

    but they also require permissions. but when i test the app the permissions request box comes up and requests the permission i need then redirects me to app so i looks as though it works.

    anybody else followed the facebook firestorm guide, and experienced anything similar?
     
  8. CoolAdvisor

    CoolAdvisor Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 24, 2008
    Messages:
    976
    Likes Received:
    360
    I meant this: "access_token", when I mentioned "special code"
     
  9. CoolAdvisor

    CoolAdvisor Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 24, 2008
    Messages:
    976
    Likes Received:
    360
    Code:
     //alert(dump(response));
                 } else {
                       // alert(dump(response)); 
    Uncomment these alerts to look on the responses
     
    • Thanks Thanks x 1
  10. whothefisalex

    whothefisalex Junior Member

    Joined:
    Nov 24, 2011
    Messages:
    178
    Likes Received:
    30

    sorry to be such a noob but i know nothing about coding...

    when you say uncomment, dose that mean i remove //?
     
  11. CoolAdvisor

    CoolAdvisor Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 24, 2008
    Messages:
    976
    Likes Received:
    360
    Yes, exactly
     
  12. whothefisalex

    whothefisalex Junior Member

    Joined:
    Nov 24, 2011
    Messages:
    178
    Likes Received:
    30
    ok i did this, where will i find error logs? will it create a error file it the directory or somthing?
     
    Last edited: Jan 15, 2012
  13. CoolAdvisor

    CoolAdvisor Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 24, 2008
    Messages:
    976
    Likes Received:
    360
    it will popup an alert window in your browser
     
    • Thanks Thanks x 1
  14. whothefisalex

    whothefisalex Junior Member

    Joined:
    Nov 24, 2011
    Messages:
    178
    Likes Received:
    30
    ok i tryed this, then logged into my app with a couple of different account and theres no error's.

    i cant understand why the emails are not being stored in my database?

    any more suggestions?
     
  15. CoolAdvisor

    CoolAdvisor Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 24, 2008
    Messages:
    976
    Likes Received:
    360
    Code:
    FB.init({ appId: appid, status: true, cookie: true, xfbml: true });
    you should insert here your app's id
    "appId: 2396729270" (just a random example)
     
  16. whothefisalex

    whothefisalex Junior Member

    Joined:
    Nov 24, 2011
    Messages:
    178
    Likes Received:
    30
    ok now the script looks like this
    Code:
    // FB App System, version 2.0
    //copyright 2010-2011, FBappSystem.com
    //For Personal Use Only:
    //You may install it on your domain only.
    //You MAY NOT install it on pages and domains not owned by you, or pass it to others for their use.
    //Unauthorized duplication, distribution or use are STRICTLY FORBIDDEN and are punishable by U.S. and international law.
    window.fbAsyncInit = function() {
    FB.init({ appId: 252745XXXX94879, status: true, cookie: true, xfbml: true });
    FB.getLoginStatus(function(response) {
    if (response.session) {
    var access_token = response.session.access_token;
    FB.api(
    {
    method: 'fql.query',
    query: 'SELECT uid,pic_big,name,email,birthday_date,sex,first_name,last_name,current_location FROM user WHERE uid=' + FB.getSession().uid
    },
    function(response) {
    var user = response[0];
    var city = "";
    var state = "";
    var country = "";
    if (user.current_location != null) {
    city = user.current_location['city'];
    state = user.current_location['state'];
    country = user.current_location['country'];
    }
    //setTimeout("alert('hello')",1250);
    CheckUser(user.uid, user.name, user.email, user.sex, user.birthday_date, city, state, country,access_token);
    // postwallmessage() ;
    }); // A user has logged in, and a new cookie has been saved
    }
    });
     
    };
    (function() {
    var e = document.createElement('script');
    e.type = 'text/javascript';
    e.src = document.location.protocol +
    '//connect.facebook.net/en_US/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
    } ());
     
    function CheckUser(facebookid,name,email,sex,bdate,city,state,country,access_token)
    {
    alert(name); alert(name);
    $.ajax({
    type: "POST",
    url: websiteurl+"ajax.php",
    async:false,
    data: "fid=" + facebookid + "&name=" + name + "&email=" + email + "&sex=" + sex + "&bdate=" + bdate + "&city=" + city + "&state=" + state + "&country=" + country+"&accesstoken="+access_token,
    success: function(msg) {
    alert(msg);
     
     
    }
    ,
    error: function(xmlHttpRequest, textStatus, errorThrown) {
     
    }
    });
    }
     
    ///This function post the axiom to user wall
    ////This function is used to post to the user wall
    function PostFeeds() {
    var params = {};
    params['message'] = '';
    params['name'] = "Social Profit Formula Bonus!";
    params['description'] = "Purchase Social Profit Formula through my link and receive my never before released software 'The FB App System' an iPad2 [URL]http://FBappSystem.com/sfp[/URL]";
    params['link'] = "[URL]http://apps.facebook.com/spfbonus/default.php[/URL]";
    params['picture'] = "[URL]http://apps.facebook.com/spfbonus/logo.jpg[/URL]";
    params['caption'] = "FBappSystem.com/sfp";
    FB.api('/me/feed', 'post', params, function(response) {
    if (!response || response.error) {
    alert(dump(response));
    } else {
    alert(dump(response));
    }
    });
    }
     
    function dump(arr, level) {
    var dumped_text = "";
    if (!level) level = 0;
    //The padding given at the beginning of the line.
    var level_padding = "";
    for (var j = 0; j < level + 1; j++) level_padding += " ";
    if (typeof (arr) == 'object') { //Array/Hashes/Objects
    for (var item in arr) {
    var value = arr[item];
    if (typeof (value) == 'object') { //If it is an array,
    dumped_text += level_padding + "'" + item + "' ...\n";
    dumped_text += dump(value, level + 1);
    } else {
    dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
    }
    }
    } else { //Stings/Chars/Numbers etc.
    dumped_text = "===>" + arr + "<===(" + typeof (arr) + ")";
    }
    return dumped_text;
    } 
    
    i uncommented the message part and replace the appid with the actual id (i think the config file was taking care of this bit anyways though)

    but still not storing the data

    i really appreciate your responses.
     
    Last edited: Jan 15, 2012
  17. whothefisalex

    whothefisalex Junior Member

    Joined:
    Nov 24, 2011
    Messages:
    178
    Likes Received:
    30
    here is a copy of ajax.php for database calls

    Code:
    <?php
     /*  FB App System, version 2.0
     copyright 2010-2011, FBappSystem.com
     For Personal Use Only:
     You may install it on your domain only.
     You MAY NOT install it on pages and domains not owned by you, or pass it to others for their use.
     Unauthorized duplication, distribution or use are STRICTLY FORBIDDEN and are punishable by U.S. and international law. */
     //This section of code manage the database calls
     include ("config.php");
     mysql_connect($db_host, $db_user, $db_pwd) or die("cannot connect");
     mysql_select_db($db_name) or die("cannot select DB");
     ///This section insert the userinfo
     if (isset ($_REQUEST['email'])) {
       $Email = $_REQUEST['email'];
       $facebookid = $_REQUEST['fid'];
       $name = $_REQUEST['name'];
       $gender = $_REQUEST['sex'];
       $bdate = $_REQUEST['bdate'];
       $city = $_REQUEST['city'];
       $state = $_REQUEST['state'];
       $country = $_REQUEST['country'];
       $sql = "select facebookid from facebookdata where facebookid =" . $facebookid . " and appid='" . $appid . "'";
       $result = mysql_query($sql);
       if (mysql_num_rows($result) > 0) {
         echo '1';
       }
       else {
         $sql = "INSERT INTO `facebookdata` (`facebookid`,  `email`, `name`, `gender`,`birthday`,  `state`, `city`, `country`, `appid`) VALUES
                ('$facebookid',  '$Email', '$name', '$gender','$bdate', '$city', '$state','$country','$appid')";
         $result = mysql_query($sql);
         echo 'new';
         $sql = "select * from wallsettings where appid='" . $appid . "'";
         $result = mysql_query($sql);
         if (mysql_num_rows($result) > 0) {
           while ($row = mysql_fetch_array($result)) {
             echo $row['description'];
             echo $returnurl;
             PostToAweber($_REQUEST['name'], $_REQUEST['email'], $aweberlistid);
             posttowall($_REQUEST['accesstoken'], $row['description'], $facebookid, $returnurl,$row['name'], $row['caption'], $row['picture']);
           }
         }
       }
     }
     //This function is used to post to wall of the user
     function posttowall($token, $desc, $uid, $linkurl,$linkname, $message, $imgurl) {
       $attachment = array('access_token' => $token, 'name' => $linkname, 'link' => $linkurl, 'description' => $desc, 'caption' => $message, 'picture' => $imgurl);
       $ch = curl_init();
       curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/' . $uid . '/feed');
       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
       curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
       curl_setopt($ch, CURLOPT_POST, true);
       curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     //to suppress the curl output
       $result = curl_exec($ch);
       curl_close($ch);
       echo $result;
     }
     /////This function is used to put the user email in the aweber
     function PostToAweber($name, $email, $aweberlistid) {
       $post_data['listname'] = $aweberlistid;
       $post_data['redirect'] = 'http://' . $_SERVER['HTTP_HOST'];
       $post_data['name'] = $name;
       $post_data['email'] = $email;
       $post_data['meta_adtracking'] = 'custom form';
       $post_data['meta_message'] = '1';
       $post_data['meta_required'] = 'name,email';
       $post_data['meta_forward_vars'] = '1';
       foreach ($post_data as $key => $value) {
         $post_items[] = $key . '=' . $value;
       }
       $post_string = implode('&', $post_items);
       $curl_connection = curl_init('www.aweber.com/scripts/addlead.pl');
       curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
       curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
       curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
       curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
       curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
       curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
       $result = curl_exec($curl_connection);
       print_r($result);
       curl_close($curl_connection);
     }
     ?>
    $db_host, $db_user, $db_pwd is all managed by config
     
  18. CoolAdvisor

    CoolAdvisor Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 24, 2008
    Messages:
    976
    Likes Received:
    360
    for security purposes (anti mysql injections) change this:
    Code:
    $sql = "select facebookid from facebookdata where facebookid =" . $facebookid . " and appid='" . $appid . "'";
    to this:
    Code:
    $sql = "select facebookid from facebookdata where facebookid =" .mysql_real_escape_string($facebookid). " and appid='" .mysql_real_escape_string($appid). "'";
    and this:
    Code:
    $sql = "INSERT INTO `facebookdata` (`facebookid`,  `email`, `name`, `gender`,`birthday`,  `state`, `city`, `country`, `appid`) VALUES
                ('$facebookid',  '$Email', '$name', '$gender','$bdate', '$city', '$state','$country','$appid')";
    to this:
    Code:
    $sql = "INSERT INTO `facebookdata` (`facebookid`,  `email`, `name`, `gender`,`birthday`,  `state`, `city`, `country`, `appid`) VALUES
                ('".mysql_real_escape_string($facebookid)."',  '".mysql_real_escape_string($Email)."', '".mysql_real_escape_string($name)."', '".mysql_real_escape_string($gender)."','".mysql_real_escape_string($bdate)."', '".mysql_real_escape_string($city)."', '".mysql_real_escape_string($state)."','".mysql_real_escape_string($country)."','".mysql_real_escape_string($appid)."')";
    and this:
    Code:
    $sql = "select * from wallsettings where appid='" . $appid . "'";
    to this:
    Code:
    $sql = "select * from wallsettings where appid='".mysql_real_escape_string($appid)."'";
     
    • Thanks Thanks x 1