Facebook share button for website - php

i need to use share button in my website. Different share button for different products.. mostly we need to use like this,
http://www.facebook.com/sharer.php?
In the above url what are all the parameters we need to pass for showing it as our website, product and some image of that product in that share page...

You asked what parameters you need to pass it to have it show up as your site, etc. The like button uses its own Graph Protocol API to do this, it essentially makes your page a facebook page and can be read as such. It's written like XML and defines things such as the thumbnail you want to show as your picture, the shortname of the site, etc. Go to developers.facebook.com to read all about the facebook API and app development and integrating into your webpage, etc.

you cand use this on github to share content on social media (includes facebook) and make your custom button!

You can use Facebook Like also. It performs the same as the Facebook share now appearing in your Facebook newsfeed with thumbnail, or
You can use some plugins like add this or you can use the following link:
<a name="fb_share" type="button" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>

Related

adding a share button for Facebook on a Wordpress site

I am trying to add a few social media share buttons to a Wordpress site I am working on and am using this for Facebook:
<img src="/img/facebook-blue.png" alt="Share this on facebook!" />
but it is not seeming to work, it produces the correct link when I inspect the code "http://www.facebook.com/sharer/sharer.php?u=http://myurl/post-name" but when I click it I get this error on Facebook:
I'm working locally, the url is: localhost:8080/videos/test-2-testing
You'll find Facebook's sharer.php won't work with any localhost URLs.
The sharer scrapes an image, title, and description from the URL it's passed. As it can't access localhost (and allowing it to try actually would create potential security holes for Facebook), you get this error.
It'll likely work just fine in production, although you'll want to urlencode the URL, like this:
<a href="http://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode(get_permalink()) ?>" ...>
In Your WordPress Admin Area, select Plugins > Add New from the menu.
Search for “ShareThis”
Install the “ShareThis: Share Buttons and Sharing Analytics” plugin.
Activate the Plugin.
This plugin can give you a facebook share button at the bottom and other buttons as well. This is what I use without having to write the code myself.

Social sharing with custom text, url and image

My requirement is to share a URL/page that is accessible only after the login!! sounds weird and meaningless but that's the requirement!! The problem is I can not use Open graph because facebook, twitter, and other social media who use Open graph will always take the title, text, and image of the login page from the meta information. So I searched and googled to get a way around to share the private URL with custom text, image, and URL. I have created some POC and have followed some plugins but nothing is helping me out.
I followed this article of "Share this":- https://www.sharethis.com/support/legacy/how-to-customize-which-url-text-and-img-to-share/ ( need to change button js to https://ws.sharethis.com/button/buttons.js )
This option is working fine for email sharing but social media is fetching the Login page meta always.
I followed this article for "Add this":- https://www.addthis.com/academy/setting-the-url-title-to-share/ (this seems to be old and they don't specify the date of the article!! )
This option is also not working and does not solve what is required.
So my question is it possible to share the page with custom title, image or description that is not accessible without login ?? if yes then any idea how to achieve this without Meta, Open graph, schema.org etc.
You tried to use OpenGraph tags on pages which require login. Facebook, Twitter and etc cannot access through obviously. Try to somehow recognize social media that request your protected content and give it to them.

How to create a like gate for a Facebook app

I'm absolutely new to coding and am trying to add a like gate to my Facebook app (a simply blog feed created using a wordpress plugin)
I really want to make a like gate for the app... ideally it would be an ajax style popup that greys out the content until the page is liked, or a transparent graphic which does the same.
Does anyone have any idea on how to do this? I'm completely stuck!
Like-Gates are usually in App Tabs, where it's possible to check if the user liked the page without forcing the user to authorize your app first. So your first step is to research how to use signed_request to determine if the page has been liked. If the page isn't liked, show the ajax popup. For the 'ajax-style-popup' you can use something like leanModal

How does the Facebook 'share' button on Stack overflow work?

I am looking to add social icons to our site, giving customers the ability to "like", tweet and share content on their facebook and twitter profiles. I have noticed to the left of this box, the facebook and twitter icons do exactly what I am trying to accomplish but I am not familiar with how to do this. Looking at the source code, there are JS references to:
<script type="text/javascript">
StackExchange.ready(function() {
var shareUrl = "http%3a%2f%2fstackoverflow.com%2fq%2f7505636%2f337690";
var shareMsg = "Advice+integrating+Facebook+%27share%27+and+link%2fimage+capabilities+with+our+site";
StackExchange.share.facebook($("#fb-share-7505636"), shareUrl, shareMsg);
StackExchange.share.twitter($("#twitter-share-7505636"), shareUrl, shareMsg);
});
</script>
Our site works this way: While anybody can visit the primary site at any time, individuals can sign up as representatives with their own unique URL that acts as a referrer to give 'credit' on rewards. I have reviewed the facebook developer site and to be honest I am slightly overwhelmed. I want to give our members the ability to click a Facebook icon from within their dashboard, prompting them to post on their wall with a set image, set title, and description. I have read in the documentation this is done by setting meta tags in the head but it does not seem to matter for my site (or I am clearly doing it wrong).
What if the URL facebook is looking for (share URL) is behind a password protected page or an area of the site which would not allow content based on a missing PHP SESSION variable?
Edit
I have also seen a lot on the net which says I have to integrate the Facebook JS SDK but then goes on to talk about authentication/permission to write on walls, etc. Yes the link to the left does not ask for permission to do anything other than to 1) log into the FB account, 2) post on the user's wall.
This site is a perfect example
The link above is great but it assumes I need to authorize a 'share' which does not occur on this site.
When you click on the share button, you call a script on facebook.com that will then in turn access the page pointed to in the querystring (?u=xxxxxx).
Facebook will parse that page and grab the first few images it finds, a description and title from the page. That is what it shows to you and allows you to add some additional text (as well as edit the title/description/and choose different images).
If that page contains the specific meta tags that facebook asks you to add to the page, then they'll use those to populate the title/description/image. This allows the webpage author to control how their page shows up in a facebook feed (although the user could still edit it before posting). These meta tags would need to be in that particular page to be used by facebook.
If facebook cannot access the page because it's password protected, etc. - then it cannot parse the meta tags and will then just show the user the URL as the title with no description and thumbnail.

custom facebook fan page

I want a facebook fan page with something like this:
With new design/theme, matching to my new website (orange/black)
Custom Logo/contents display
30 boxes short description, on mouse hover, get some highlight for box and on click of specific box, opens a new pop-up
pop-up should contain more detailed description and a link to specific page on my website
I think above things are achievable using FBML but any good ref/guide would be appreciated to help me quickly develop such a thing.
FBML is being deprecated by Facebook. You can create an iframe application instead. In an iframe you can basiclly do anything you like. As for themeing the page, you can't touch the facebook design. You can only control the contents of the iframe itself. You can however upload an image for the "profile picture".
Here is a guide for iframe apps for your reference:
http://www.hyperarts.com/blog/adding-iframe-application-to-facebook-fan-page/
Here is the reference site where you find the full demonstration of custom FB fan page.
You can achieve that using fb api.
http://www.kimwoodbridge.com/how-to-create-a-custom-facebook-fan-page/
http://blog.theunical.com/facebook-integration/simple-steps-to-publish-on-facebook-fan-page-using-php/
http://www.webdigi.co.uk/blog/2010/creating-a-custom-facebook-page/

Categories