Facebook how to create button that share content with 1 click? - javascript

I have seen on many websites who have a button. That share a story to yours facebook profile when you click on it. I have tried the Facebook Share button, but a dialog appears.
How do I create a Facebook share button that share content with only 1 click?

you need to use open graph api in Facebook or add meta tags in the <head> </head> of your pages, where your share button is placed.
look at this section, Sharing Rich Media
But you should use Like button instead, Share button is deprecated by Facebook.

Facebook has many restrictions concerning sharing content. There are a few roadblocks to one-click sharing.
What you tried used the Feed dialog, which is the easiest way to share content to a user's profile or timeline. However, this brings users to a Facebook.com url where they must approve the content and enter their own message. You can set certain parts of what is shared (URL, title, description, etc), however under most circumstances you may no longer set the message that is shared. See http://developers.facebook.com/docs/reference/dialogs/feed/ for more details.
On the other hand, you can use Facebook Auth to publish to a users stream using the publish_stream permission. However, this is an advanced technique that requires extra work on the part of the developer. You must create an application, allow the user to login, and request the publish_stream permission from the user. After gaining permission, publishing to their stream can be accomplished with 'one-click,' or by simply using using javascript or server-side code.
The simplest solution is obviously using the Feed dialog, which is two-clicks, but a whole lot easier than Authentication.

Related

Is there a way to perform a "Submit" function outside of the website?

I am trying to figure out if it is possible to click on a button on the Amazon website from outside of the website.
For Example: At the bottom of every product review is a "Helpful" button. If a review was helpful, the reader/shopper can click this button to let the reviewer (and Amazon) know that the review was helpful. (It's basically a "Like" button).
What I'm trying to accomplish:
I want to post my reviews on my own website/blog and still obtain "Likes" without asking readers to click a link to a product page, then search for my review, then click the button.
You probably won't be able to do what you have in mind.
JavaScript can generally access information on another domain except if specifically configured in the origin website through CORS. Unless you own amazon.com, you won't be able to configure amazon's CORS headers to make them accessible to some JS running on your website.
You can however, from your website front-end, make a request to your website back-end that would be able to access amazon's data just like your browser does. Using a browser emulator like Puppeteer, you'll be able to launch an amazon page and programmatically retrieve infos, click on things and do other stuff.
However, the page that Puppeteer will be able to spin up will include credentials (cookies, localstorage content, auth token, etc) provided by your server, so Puppeteer will not see the same amazon.com your user sees on his browser, unless your user agrees to give you its amazon credentials, and at this point I'm pretty sure no user would do that, and that would not be authorized by amazon's terms of services.
TL;DR even if what you have in mind is not impossible, it would weeks for your and your team to code a system that would potentially allow you to do that, and that's provided the law is on your side, which is probably not the case.

How to give permission to user for download files from website after sharing it on Facebook?

I want that when user try to download any pdf/doc/zip file from my website then first of all user will share something about my website on his/her Facebook wall and after successfully share download link will enable.
I got one solution for this question on Stack Overflow but this is not 100% correct. Because this solution is able to share on Facebook but after share the download link is not appear. The Below link is solution for Stack Overflow answer.
Is it possible to add a link to download a file that can only be downloaded by sharing it on Facebook?
Facebook changed the behavior of it's share dialog recently. Before that, the dialog sent a response which included the post id when something was successfully shared, and did not when it wasn't without the need of having the user authenticated.
However, currently Facebooks share dialog does not send the post ID along with the response when the user is not connected to your application and did not grant the publish_actions permission for your app.
Regarding the post_id the docs state:
Only available if the user is logged into your app using Facebook and has granted publish_actions. If present, this is the ID of the published Open Graph story.
If you want to do it anyways you have to go through the whole mess of the authentication flow, which probably isn't worth it.
Additionally requesting the publish_actions permission will require your app to be reviewed. Since gating of any kind is not permitted by facebook, the publish_actions permission will not get approved. Currently there is no way to implement this feature.
See Facebooks Developer Platform Policy (4.5)
(thanks to luschn for the hint)
That all breaks down to a few principles:
Deliver good content and do not make it dependent on user interaction
Do not force the user to socially interact with your application. If they want to they'll do so on their own behalves
At least the Javascript SDK is a pain to implement properly. Avoid it whenever possible. Use Social Features as an additional bonus and not a necessity.
Facebook changes it's API every now and then. The API is incredibly unreliable which forces you to make changes to your code every few months if it heavily relies on Social Features.

Take screenshot via PHP and Javascript

I have a chat system and I want to protect my users from malicious websites, and sometimes people sends a URL through the chat system, and users click on it and access some scam sites. I have that protect page like redirect.php?url=someurl.com that alerts the users that URL can be a malicious website, and the users have to click on Continue button to access the link. But I want to give them one more option which is See a preview, and clicking on it, a new tab will be opened with a screenshot, or if it's not possible only with PHP and Javascript, show a clean version of the page without Javascript.
How can I do this?
I'm planning of make use of file_get_contents(), save it to some preview text, cleaning the <script> tag of the page, but it'll be enough?
Lots of such screen capture web service here:
What's the best website screenshot capture API?
But instead of doing that by yourself, I think you should go with those many public link-shortening service, like t.co, because anti-malicious is already one of their purpose:
Having a link shortener protects users from malicious sites that
engage in spreading malware, phishing attacks, and other harmful
activity. A link converted by Twitter’s link service is checked
against a list of potentially dangerous sites. Users are warned with
the error message below when clicking on potentially harmful URLs.
Try this solution :): html2canvas
[outofdate] http://html2canvas.hertzen.com/screenshots.html
--
Update: http://html2canvas.hertzen.com

how to use Facebook share button in my web page to share or post something to facebook page?

i am added a facebook share button to my website it is sharing or posting things to profile timelines but it is not sharing or posting anything to my page(like fans page in facebook).Is there anyway to choose to post to your fan page? any one can help me? plz..
Considering whatever is the "things" in your website, say a product with id 123, for example.
You can make users like it/share it using the standard fb-like button.
When they do like it and/or share it, it comes up as a thing they liked on your website. If that object of yours, has a proper URL with proper meta-tags, it will show up nicely on FB as a story. Good guide here
You can also use the facebook debug tool for testing if the sharing, meta tags are all working as expected here.
If you want your page to be the object of sharing, the only thing that can be done is users can like your page from your website. You cannot share stories from the API to the page, as the page is not an entity. Meaning its not a user.
So, if the page said,
User XYZ liked item ABC on yourwebsite.com
it won't make much sense to the people who see this.
Instead if userXYZ liked an itemABC on your site, the following update on FB will make much more sense.
UserXYZ liked itemABC on yourwebsite.com
(This will have a proper pictorial representation and a clickable link to your website if the like button and the destination url are configured correctly)

Alternate methods to invite friends to facebook

I am working on a fan page and currently I am using an iframe app with the facebook send button embedded in it. I was wondering if there was a better way to invite people to a fan page, like a dialog box that opens with the list of the users friends, the user can then choose his/her friends and send invites. Is this still possible, since FBML tags have been deprecated. Thank you.
Regards
Ghulam Mustafa Majal
You can use our requests channel if you're making an iframe app on facebook which will allow your user to select and send a 'request' to their friends. Then you'll just want to make sure and how the like button on your landing page so when other users receive the request, they can like your fan page as desired.

Categories

Resources