There is a commenting system in my php application. If user already logined in facebook then I have to hide Name section in my add comment form, If not it need to show Name and comment fields.
Also for displaying comments I need to show user's facebook name and profile thumb.
I tried a lot in developer.facebook site.
Please help me. Thanks in advance
With the facebook php-sdk, you can get the logged-in user's info with this code:
$user = $facebook->api('/me');
giving of course if the user authorized your application. You can also display the user's profile picture with:
<img src="http://graph.facebook.com/<?php echo $facebook->getUser(); ?>/image" />
or you can just use the facebook comments plugin: http://developers.facebook.com/docs/reference/plugins/comments/
<?php
require_once('../src/facebook.php');
$fb_app_id = "id";
$fb_secret = "key";
$fb_app_url = "url";
$facebook = new Facebook(array(
'appId' => $fb_app_id,
'secret' => $fb_secret,
'cookie' => true,
));
$facebook_login_url = $facebook->getLoginUrl(array(
'canvas' => 1,
'fbconnect' => 0,
'scope' => 'publish_stream,user_photos',
'redirect_uri' => $fb_app_url
));
echo $facebook_user_id = $facebook->getUser();
?>