开发者

adding facebook share button to a dynamically generated web page

开发者 https://www.devze.com 2023-03-14 00:43 出处:网络
I need to add facebook twitter and google +1 button to a dynamically generated web page. I am explaining my use case here:

I need to add facebook twitter and google +1 button to a dynamically generated web page. I am explaining my use case here:

User comes to my web portal which is a java/j2ee based web portal and adds few content (e.g. name,address, company, designation, place and also his picture.)

Then, I am generating a page like facebook profile page, www.mydomain.com/user_name.

So my goal is to add his contents along with the url and picture to his/her facebook wall using facebook share button.

I went through few codes that I got, one simple example is:

<a href="javascript:window.开发者_StackOverflow社区location=%22http://www.facebook.com/sharer.php?u=%22+encodeURIComponent(document.location)+%22&#38;t=%22+encodeURIComponent(document.title)" title="Share on Facebook..."><img src="/path/to/your/image/" width="12" height="12" alt="alt" /></a>

Can I enhance the same code to get my needs done? Also I need to twitter the same content. But I am not able to do it dynamically. How do I do that? Any reference or tutorials or code sample would be helpful.


<a href="http://twitter.com/share" 
   data-url="http://your.url.com/yourdynamicpage" 
   class="twitter-share-button" 
   data-text="What should I share?" 
   data-count="horizontal">
Tweet
</a>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>

This will work


If you are dynamically generating a web page, that means you are filling the content with data taken from either get / post or a database.

If you are already using this data to fill in other content, why would you not be able to use this data to populate the parameters of the Facebook share url?

0

精彩评论

暂无评论...
验证码 换一张
取 消