facebook twitter

i am working on an ecommerce website

each product has its own page with its own web address url (website.com/product1.php)

I am told to add
facebook like button
twitter button

what do these buttons do
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kevin CrossChief Technology OfficerCommented:
For the Facebook Like, please see http://developers.facebook.com/docs/reference/plugins/like/
After you generate the code you want, you should see something similar to this:
<div class="fb-like" data-href="http://website.com/product1.php" ...></div>

Open in new window

Per the documentation, "The XFBML version defaults to the current page." Therefore, if you are using the Javascript SDK (http://developers.facebook.com/docs/reference/javascript/), then you do not need to worry about specifying the URL.
In that case, the data-href attribute should be removed:
<div class="fb-like" ...></div>

Open in new window

If you need to use the other method, then change the data-href to be dynamically filled by PHP code however you like. One option is by using server variables http://php.net/manual/en/reserved.variables.server.php.

For the Twitter button, please see http://twitter.com/about/resources/tweetbutton. Same thing as above. There is an option that to use "The URL for the page the button is on." If you want control over the URL, the attribute there is data-url.

Hope that helps!


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kevin CrossChief Technology OfficerCommented:
It looks like I took too long to type all that out, but hopefully there is something useful to add to the first Expert's post.
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

You definitely added something useful :)

I'm not a PHP pro so I didn't go into the detail you did, but then again the question wasn't asking how to code it so I felt comfortable replying.
Kevin CrossChief Technology OfficerCommented:
And for the second part of the question, those buttons are for socialization through the sites specified. This is important with the search algorithms of providers like Google where the fact that users actually Like or have linked to your site via Twitter helps with rankings. Aside from that, if Marketing of your content is important, they help you get targeted advertising. i.e., being a database person, most of the people that read my tweets like database information, so are more likely to read a page I tweet. It is just a way to get to target customers through social engineering. :)
rgb192Author Commented:
I understood the facebook button,
how can I work the twitter button

I was not given the html code on twitter

Did you read the links I posted?  All the info you need is in both of those links.

Aside from that, the link you just referenced has an output box of the HTML code constructed from what you put into the text boxes.
Another link for you to read.
rgb192Author Commented:
both great answers, thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.