×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    3

    Facebook Connection from widget

    Hello, I'm trying to connect my widget with facebook. Does anyone know how to do that? I only need to read and publish in the newsfeed but I can't even authenticate to the system. Is there any widget that already do this? Or is there any prefered method/API I can use?

    Thanks,
    Jose Campo

  2. #2
    Registered User
    Join Date
    Feb 2010
    Posts
    2

    Re: Facebook Connection from widget

    Yeah i would like to know how to do this too..
    I did a lot of research, and found out that you need to make an application on facebook (no code, just sort of register it) so u can get an API key.
    The part where i'm stuck is this bit.. If i'm right then u need a Facebook Connect URL, even if ur making a mobile application.
    Where does this url come from? Since i dont have a website, just the mobile app.
    So basically, how can i implement the basic functionality of logging in and publishing to the stream..?
    I'm using aptana studio 2.0 with the WRT plug-in with JavaScript offcourse.

  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2011
    Location
    bucharest
    Posts
    151

    Re: Facebook Connection from widget

    I got stuck @login

    the FBlogin button is in IFRAME and apparently has "javascript:window.open" and does not work under WRT environment should have "javascript:widget.openURL"

    the FBlogin button works in mobile browser, but not in WRT (

    keep looking for a solution..

    the only solution that I have is for example to "connect to facebook" only my top from games... although the top will open in a browser

    Code:
    <?php
    
    define('YOUR_APP_ID', '*********');
    define('YOUR_APP_SECRET', '*******************');
    
    function get_facebook_cookie($app_id, $app_secret) {
      $args = array();
      parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args);
      ksort($args);
      $payload = '';
      foreach ($args as $key => $value) {
        if ($key != 'sig') {
          $payload .= $key . '=' . $value;
        }
      }
      if (md5($payload . $app_secret) != $args['sig']) {
        return null;
      }
      return $args;
    }
    
    $cookie = get_facebook_cookie(YOUR_APP_ID, YOUR_APP_SECRET);
    
    $user = json_decode(file_get_contents(
        'https://graph.facebook.com/me?access_token=' .
        $cookie['access_token']));
    
    $friends=file_get_contents(
        'https://graph.facebook.com/me/friends?access_token=' .
        $cookie['access_token'])
    ?>
    <html>
      <body>
        <?php if ($cookie) { ?>
          Welcome <?= $user->name ?>(<?= $user->id ?>)<?= $user->id ?>
          <?= $friends ?>
        <?php } else { ?>
          <fb:login-button></fb:login-button>
        <?php } ?>
        <div id="fb-root"></div>
        <script src="http://connect.facebook.net/en_US/all.js"></script>
        <script>
          FB.init({appId: '<?= YOUR_APP_ID ?>', status: true,
                   cookie: true, xfbml: true});
          FB.Event.subscribe('auth.login', function(response) {
            window.location.reload();
          });
        </script>
      </body>
    </html>
    Last edited by shpe; 2011-11-28 at 08:58.

Similar Threads

  1. Connection times out after 10 requests...
    By QSIPhone in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2007-04-09, 17:29
  2. connection to serial port
    By marluzch in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2006-11-20, 19:47
  3. MMS Interruption during GPRS connection hangs the device?
    By alexhong in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2004-08-31, 18:47
  4. MMS Interruption during GPRS connection hangs the device?
    By alexhong in forum Mobile Java General
    Replies: 0
    Last Post: 2004-08-31, 18:45
  5. Replies: 5
    Last Post: 2003-02-07, 11:25

Posting Permissions

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