Why am I not able to share my webpage link on Facebook?
The code looks fine to me, but I have no clue why is it not bringing up the FB popup and sharing my site.
here is the js part
function streamPublish(name, description, hrefTitle, hrefLink, userPrompt){
FB.ui(
{
method: 'stream.publish',
message开发者_StackOverflow: '',
attachment: {
name: name,
caption: '',
description: (description),
href: hrefLink
},
action_links: [
{ text: hrefTitle, href: hrefLink }
],
user_prompt_message: userPrompt
},
function(response) {
});
}
function showStream(){
FB.api('/me', function(response) {
//console.log(response.id);
streamPublish(response.name, 'Connect with Abhishek Raj Simon on his new website http://abhisheksimion.cjb.net', 'hrefTitle', 'http://abhisheksimion.cjb.net', "Share abhisheksimion.cjb.net");
});
}
html
<a id="fbanchor" href="#" onclick="showStream(); return false;">Like it, Share it!</a>
Can somebody point out, where am i going wrong? You can visit the work in progress website http://abhisheksimion.cjb.net
I get a javascript error:
Error: showStream is not defined Source File: http://users.cjb.net/abhisheksimion/ Line: 1
I think in your script tag, line 128, that closing bracket should be higher, to close off the fqlQuery()
function. As written, showStream()
is part of the fqlQuery()
function, which causes showStream()
to fail.
If all you are trying to do is add basic facebook functionality like "Like" and "Share" this can be achieved without using heavy javascript.
https://developers.facebook.com/docs/reference/plugins/like/
https://www.facebook.com/sharer/sharer.php?yoursite.com
Where 'yoursite.com' is the site you want to share. You can use opengraph tags to specify the content.
精彩评论