Facebook Status Updates From Website

Discussion in 'Web Design and Development' started by SChaput, Jan 22, 2010.

  1. SChaput macrumors regular

    Joined:
    Jul 2, 2008
    Location:
    United States
    #1
    I'm interested in allowing my users a way to automatically update their facebook status' from my website. For instance, I would have a link and when users click it they are brought over to facebook's page, where they would authenticate themselves, if they are not already, and some bit of content from my page would automatically fill into their status update. And once permission was given by the user, it would update their status.

    Is something like this possible?

    I've done some research into the facebook status.get api available here. But i believe that this is only for facebook applications, and not a website accessing facebook.
    I have also looked into some of the facebook widgets, such as the one seen here This is very close to the same thing i am looking for, but it 'shares' content, and the status itself is not editable, as far as i can tell.

    Any help or guidance is greatly appreciated! Thanks.
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
  3. SChaput thread starter macrumors regular

    Joined:
    Jul 2, 2008
    Location:
    United States
    #3
    Thank you for the quick reply. That is close to what i was looking for, and maybe i'm being picky, but i would really like the status itself, not just share a link.

    As usaul, after posting my question i found this website, which seems to explain the process i want to utilize. I'm working my way through it now, if anyone has any better solutions, id be happy to hear them

    Thanks again
     
  4. SChaput thread starter macrumors regular

    Joined:
    Jul 2, 2008
    Location:
    United States
    #4
    I'm having some issues getting the basics down. I think its really simple but im missing something crucial.

    [​IMG]

    Above is the file structure of my website, and i'm using http://fbcookbook.ofhas.in/2009/02/07/facebook-reveals-status-api-how-to-use-it/ to help me. The file index2.php has the code that is seen on the link above, the begining looks like this
    Code:
    include_once("/footprints/config.php");
    if (!$facebook->api_client->users_hasAppPermission("status_update")){
    echo '<fb:prompt-permission perms="status_update" next_fbjs="greet()">Let us update your status from this application</fb:prompt-permission>';
    $visibility = "none";
    
    However, im getting an error on index2.php that says,
    Fatal error: Call to a member function users_hasAppPermission() on a non-object in /home1/ihatemyr/public_html/thebook/index2.php on line 3

    How can i combat this issue? is there an issue with my config file or what?

    Thanks
     
  5. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #5
    The first line
    PHP:
    include_once("/footprints/config.php");
    is pointing at a file at the root of the web server rather than the root of your web site. When doing paths in PHP, it's different than with HTML and CSS. You need the full path. Use the following,
    PHP:
    include_once $_SERVER['DOCUMENT_ROOT'].'/footprints/config.php';
    That's at least one issue. The other, the code references the $facebook variable, but that isn't declared in your code. It gets declared in footprints/index.php. That footprints folder is an example implementation from the looks of the readme file. Creating that index2 file may not work right.
     
  6. SChaput thread starter macrumors regular

    Joined:
    Jul 2, 2008
    Location:
    United States
    #6
    Thank you for pointing those issues out, however i'm still finding myself not getting very far with this.

    I replaced the index.php file under the footprints directory with this code:

    Code:
    <?php  
    include_once("config.php");  
    if (!$facebook->api_client->users_hasAppPermission("status_update")){  
    echo '<fb:prompt-permission perms="status_update" next_fbjs="greet()">Let us update your status from this application</fb:prompt-permission>';  
    $visibility = "none";  
    }  
    else  
    $visibility = "block";  
      
    if(isset($_POST['status']))  
    {  
        $facebook->api_client->users_setStatus($_POST['status']);  
        echo "<p>Your status has been updated</p>";  
    }  
    ?>  
    <div id="statusdiv" style="display:<?=$visibility;?>;">  
        <form method="POST">  
            Please update your status:<br/>  
            <input type="text" name="status" /> <br/>  
            <input type="submit" value="change status" />  
        </form>  
    </div>  
      
    <script>  
    function greet()  
    {  
        var session = "<?=$facebook->api_client->session_key;?>";  
        document.getElementById("statusdiv").setStyle("display","block");  
        new Dialog().showMessage("Info","Thank you for granting us this permission! Now you can update your facebook status directly from here.");  
    }  
      
    </script>  
    
    And config.php file looks like this:
    Code:
    <?php
    
    // Get these from http: developers.facebook.com
    $api_key = '';
    $secret  = '';
    /* While you're there, you'll also want to set up your callback url to the url
     * of the directory that contains Footprints' index.php, and you can set the
     * framed page URL to whatever you want.  You should also swap the references
     * in the code from http://apps.facebook.com/footprints/ to your framed page URL. */
    
    // The IP address of your database
    $db_ip = '*******';           
    
    $db_user = '******';
    $db_pass = '******';
    
    // the name of the database that you create for footprints.
    $db_name = 'footprints';
    
    /* create this table on the database:
    CREATE TABLE `footprints` (
      `from` int(11) NOT NULL default '0',
      `to` int(11) NOT NULL default '0',
      `time` int(11) NOT NULL default '0',
      KEY `from` (`from`),
      KEY `to` (`to`)
    )
    */
    
    WIth certain parts removed.

    And going to the website i recieve this error:

    Fatal error: Call to a member function users_hasAppPermission() on a non-object in /home1/ihatemyr/public_html/thebook/footprints/index.php on line 3

    I have no idea where to go from here, any help is greatly appreciated.
     
  7. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #7
    I meant to ask this before, but did recommend looking at the readme file. Do you have an API key for the Facebook API? It goes in that config.php file. You have it empty and I'm not sure if that's just for here or if you don't have one.
     
  8. glowfly macrumors member

    Joined:
    Jan 13, 2010
    #8
    i think you can do that by integrating your website with facebook connect although im not sure ...
     

Share This Page