Adding a facebook share button to a dynamically created web page

I need to add facebook twitter and google +1 button to a dynamically generated webpage. I explain my usage example:

A user comes to my web portal, which is a web portal based on java / j2ee, and adds some content (for example, name, address, company, name, place, as well as its photo.)

Then I create a page, such as a facebook profile page, www.mydomain.com/user_name.

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

I looked through a few codes that I have, one simple example:

<a href="javascript:window.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 improve the same code to fulfill my needs? I also need to scroll through the same content. But I can not do it dynamically. How can I do it? Any link or tutorials or sample code would be helpful.

+4
source share
2 answers
 <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> 

It will work

+2
source

If you dynamically generate a web page, it means that you are populating the content with data received from get / post or the database.

If you are already using this data to fill out other content, why not use this data to fill out your Facebook sharing settings?

+1
source

All Articles