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

need FBML help - insert profile picture into ap

Discussion in 'FaceBook' started by leedaman, Nov 1, 2010.

  1. leedaman

    leedaman Junior Member

    Joined:
    Sep 7, 2009
    Messages:
    132
    Likes Received:
    27
    hi
    i am making an applicationthat requires the current users profile picture to be shown
    i have tried the
    Code:
    <fb:profile-pic uid="loggedinuser" linked="false" size="normal" />
    but pic isnt showing

    any clues why guys

    this is on a iframed html page that is in a fbml application

    thanks for help
     
  2. locknload007

    locknload007 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 14, 2010
    Messages:
    475
    Likes Received:
    67
    You also could use

    Code:
    <img src="http://graph.facebook.com/loggedinuser/picture?type=large" border="0" align="right" style=" overflow:hidden; height:100px;">
     
  3. leedaman

    leedaman Junior Member

    Joined:
    Sep 7, 2009
    Messages:
    132
    Likes Received:
    27
    hi thanks for your help
    i tried that also and it is still not showing

    Code:
    <tr>
           <td width="345"><img src="http://graph.facebook.com/loggedinuser/picture?type=large" border="0" align="right" style=" overflow:hidden; height:100px;"></td>
            
    
    arrr this is driving me nuts
     
  4. dsipal

    dsipal Newbie

    Joined:
    Sep 9, 2010
    Messages:
    20
    Likes Received:
    1
    I think you may have to have the permissions to use their basic information.
     
  5. locknload007

    locknload007 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 14, 2010
    Messages:
    475
    Likes Received:
    67
    hange loggedinuser to whatever you are using to capture their id. You dont need any special code to pull their photo using the open graph, that is the point of it.

    I use to use

    Code:
    include_once "config.php";
    include_once 'facebook/footprints/config.php'; //has $api_key and $secret defined.
    include_once 'facebook/php/facebook.php';
    ****** $api_key,$secret;
    $fb=new Facebook($api_key,$secret);
    $fb_user=$fb->get_loggedin_user();
        
    ?> 
    <? 
    if($fb_user){
    So you would use the $fb_user, but you need to use whatever method you are using to get their id and replace the loggedinuser with it


    Look like this is the code for Open Graph

    Code:
    <?php
    
    define('FACEBOOK_APP_ID', 'your application id');
    define('FACEBOOK_SECRET', 'your application secret');
    
    function get_facebook_cookie($app_id, $application_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 . $application_secret) != $args['sig']) {
        return null;
      }
      return $args;
    }
    
    $cookie = get_facebook_cookie(FACEBOOK_APP_ID, FACEBOOK_SECRET);
    
    ?>
    <?php if ($cookie) { ?>
          Your user ID is <?= $cookie['uid'] ?>
        <?php } else { ?>
          <fb:login-button></fb:login-button>
        <?php } ?>
    
    
    <?= $cookie['uid'] ?> is what you would then put in the place of loggendinsuer
    
    To test that code out I gave you just put in your or a friends profile id/username in place of loggedinsuer, it is just a normal img link, so put it anywhere you want the image to show up


    Here you go

    http://graph.facebook.com/112023445489802/picture?type=large
     
    Last edited: Nov 1, 2010
  6. Grizzy

    Grizzy Senior Member

    Joined:
    Nov 11, 2008
    Messages:
    919
    Likes Received:
    999
    On a canvas page uid="loggedinuser" should work fine even if the user has not connected to your app. Otherwise you will need to acquire basic information permission. You can also just contruct a graph url like Chrarles said if you can get the id somehow..
     
  7. locknload007

    locknload007 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 14, 2010
    Messages:
    475
    Likes Received:
    67
    OK, I should step back a little. If you mean FBML as in a tab, using Static FBML, then it is a little more difficult than what was presented here. 6 Months ago when I was doing apps and really into it, I think it was possible, but not easy to do.

    If you are talking your page being iframed and putting fbml inside of your pages, or doing a canvas page, then it can be done with what is mentioned here.

    Things have changed some, but I what I just said is correct, and since they are going away from fbml, might even make me feel more like I am right.
     
    Last edited: Nov 1, 2010
  8. leedaman

    leedaman Junior Member

    Joined:
    Sep 7, 2009
    Messages:
    132
    Likes Received:
    27
    no yhis is a fbml application they have granted permisions already

    so you are saying if the uid was put into the DB table uid i would need to
    use $uid in place of loggedinuser

    i really need to learn php i have been copy and pasting shit for years
     
  9. locknload007

    locknload007 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 14, 2010
    Messages:
    475
    Likes Received:
    67
    I just checked and the Open Graph bit of code did produce my id.