need FBML help - insert profile picture into ap

leedaman

Junior Member
Joined
Sep 7, 2009
Messages
132
Reaction score
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
 
You also could use

Code:
<img src="http://graph.facebook.com/loggedinuser/picture?type=large" border="0" align="right" style=" overflow:hidden; height:100px;">
 
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
 
I think you may have to have the permissions to use their basic information.
 
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:
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..
 
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:
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
 
I just checked and the Open Graph bit of code did produce my id.
 
Back
Top