javascript - Trying to get response.name or id -
on page, people can press share button , post on facebook. use code:
window.fbasyncinit = function() { fb.init( { "appid" : "<?php echo $fbid; ?>", "status" : true, "cookie" : true, "xfbml" : true, "oauth" : true });
on click function showstreampublish starts:
function showstreampublish() { fb.ui( { method: 'feed', name: 'text', caption: 'text', link: 'link', picture:'pic', description: 'ni', user_message_prompt: 'share it!' }, function(response) { if (response && response.post_id) { fb.api('/me', function(response) {alert(response.name); }); ...
where use following code wanna show username of person did sahre doesnt :(
fb.api('/me', function(response) {alert(response.name); });
how can username or userid of persob did share? opens alert-box - "undefined" content. thank help.
i tried response.status , weird thing is: if connect through app , post on facebook, message i`m not connectet through app. using code:
if (response.status === 'connected') { // user logged in , has authenticated app alert('all good'); }else if (response.status === 'not_authorized') { // user logged in not through app alert('not good'); }else{ alert('what heck?');// user isn't logged in facebook. } });
neil
i see 2 things don't feel good:
- the
fb.api
call includedfb.ui
. - you use
response
twice:fb.ui({...}, function(response) {...
,fb.api('/me', function(response) {...
.
both problems may related or not. make it:
function showusername() { fb.api('/me', function(response) { alert('post published ' + response.name); }); } function showstreampublish() { fb.ui({ method: 'feed', name: 'text', caption: 'text', link: 'link', picture: 'pic', description: 'ni', user_message_prompt: 'share it!' }, function(response) { if (response && response.post_id) { showusername(); } else { alert('post not published.'); } } );
Comments
Post a Comment