Facebook: Posting multiple links using graph API (javascript sdk) - javascript

My requirement is in such a way that when the user clicks on the button, content similar as below has to be posted on the user's wall from our site.
Sample Sharing Content
I like the following pages in xyz.com
1. link 1
2. link 2
3. link 3
4. link 4
Is this achievable through facebook graph API[javascript sdk]? If so how can it be done?
EDIT
Currently I am able to do the above but I wanna share a link with a clickable text and url. For example instead of displaying http://www.google.com, I want to display Google as the url text.
Instead of having this http://www.google.com, I wanna do this Google
Can that be done? Is it possible through API?

Yes, it is possible. You first have to register an app on Facebook. Then you create a login for the user with the right permissions. And finally, you make an Api call to publish your content to their wall.
Registering app & login: http://developers.facebook.com/docs/howtos/login/getting-started/
Api call: http://developers.facebook.com/docs/reference/javascript/FB.api/
Let me know if you have any questions..

I think you want something like collections. Take a look at this example image.
This cannot be done in an quick way. You need to fiddle around with the open graph and its actions. This might be a lot to do at first, but the results are very nice (as the different screenshots/app examples demonstrate). The docs are quite good on the basics and there are plenty of ressources on how to archive advaned stuff. But the basics should be enough for a simple link list. Note that this is not just result in "regular" wall post but a collection of links in the users profile, that can also appear on his wall.
You cannot just use "vanilla HTML" to post these collections of link like you want to since it is neither supported, proposes good security not UX compatible.

Related

Embed Dynamic Instagram Feed Into HTML With Code Only (NO API/Plugin)

I am looking to get started on how to embed an entire dynamic Instagram feed using HTML and JavaScript (if possible/if necessary) instead of using API's and plugins.
Essentially, what I want on a page for a website that I am currently working on is to show all of the posts as part of a feed on a website and whenever a new post is uploaded on Instagram, that newest post to load automatically.
Does anyone know how to do this or how I can get started on this please?
A little late to reply, but hopefully this is helpful for someone...
Firstly, so we're on the same page, you WILL need to use at least one API to do this-- the Instagram API. You need to use the Instagram API in order to fetch content from their service (this article explains the basic idea https://www.freecodecamp.org/news/what-is-an-api-in-english-please-b880a3214a82/)
Now, you do not say whether you've looked at the Instagram developer docs, but this would be a great place to start: https://developers.facebook.com/docs/instagram
It looks like they have some example code and tutorials, so hopefully there is enough info here to get you started! Based on your question, it sounds like you may want to first check out their BasicDisplayAPI: https://developers.facebook.com/docs/instagram-basic-display-api
Finally, you might find this other SO post helpful. Unfortunately the blog link is broken, but the code snippet looks promising
Embed an instagram feed
This blog article looks promising as well:
https://dev.to/ljcdev/embedding-an-instagram-post-in-your-website-3666

Embed a Facebook Page Post including Comments

I've been looking at how to embed a Facebook Page Post using this documentation. I like the way this looks, but it doesn't allow for the comments to also be shown at the same time. My goal is to create a dashboard of page post and display it on a TV in the hallway. None of the posts have more than 10 comments so it wouldn't get out of hand. Is there a way to accomplis this using the api I linked, or do I need to spin up my own iframe to include the comments?
It appears the best way to list the comments of a Facebook page post is to use the Facebook Graph API. Here is a direct link to the comments API:
https://developers.facebook.com/docs/graph-api/reference/v2.5/object/comments

Writing a comment onto a 3rd party facebook wall via website link

Really wracking my brains about how to do this but i basically dont even know where to start.
Basically twitter has functionality that allows a link to open a twitter box that a user can populate and then post directly onto a chosen twitter feed:
https://about.twitter.com/resources/buttons#mention
Its super simple, all it requires is changing the URL parameters of the target link.
Im trying to do something similar with facebook. Ideally a link clicked on my site would open a facebook page with a prompt for user to type their comment and login to post to the 3rd party wall. I definitely do not want to be handling any FB authentication on my end as i imagine this would be far beyond my rather novice coding abilities.
An alternative would be to capture the comment with a text box on my end and then pass this through to facebook to write onto the wall.
Ive trawled the net and stack exchange looking for solutions but most seem to be geared to putting a comment on the users wall rather than a 3rd party.
Honestly im not super active on any social media anyway so my knowledge of how they function is quite limited. If anyone could give me a steer and some possible solutions (or alternatively just out and out that it is impossible) that would be fantastic.
You can use the Facebook JavaScript SDK, and invoke the feed dialog using that.
The feed dialog has a to parameter into which you can fill the Facebook ID of the profile that you would like the user to post to. However, the profile who's ID you fill in there must have authorized the same app as the one that you initialized the SDK for. That means this approach is likely impractical.
In any event, here's a piece of example code.
If you would like to use graph API to post to a profile's timeline (using the profile-ID/feed POST endpoint), you'll have to implement Facebook Login as well. However, since Graph API v2.0 is mandatory for all apps now, you can only find those profile IDs of people who have also authorized the same app.
This is probably even less practical for you, given that you don't want to implement Facebook login.
As far as I can see, these are your only options to achieve what you are looking for at this time.

Creating a facebook likebox

A client of mine (a design studio) asked me to style the like-box social plugin on their site.
As far as I know this cannot be done now with the deprecation of "css" parameter on the fbml tag.
So the route I have to take is to recreate the like-box myself using the js SDK (or php SDK), but the problem is that I cannot find the users (and their photos) that like my page. I'm searching through the opengraph explorers parameters but i cannot find anything.
Does anyone know which url I must follow in the graph api to get what I want?
Do I have to have an access token for such an action? I noticed that the likebox plugin works event if you don't have a facebook account (It shows pictures).
Thank you.
You can't recreate the like box on your own. The Facebook APIs will not return a list of users who like your object. This was done to stop people from getting user lists of likers and spamming them.
Currently, you can only query to find if a specific, authenticated user or which of their friends likes your object.
You could build something similar by populating your fake like box with images of recent posters. You would need to deal with filtering out duplicates, and the page posting as itself, but this should get you started: /PAGE_ID/feed?fields=from.name,from.picture&limit=10
You will need an access_token to get this data. I'd authenticate as an app to do it.

Add something to Facebook stream via URL

I have a userscript (read: my Javascript on someone else's site) that allows users to share their IMDb votes with their Facebook friends. I just generate a URL for a Facebook share page with all of the custom information needed for the specific situation, something like "So and so gave the film Forrest Gump a rating of 9/10 on IMDb" with links to a thumbnail and the movie page itself, and allow the user to add their their thoughts on the movie itself.
script with Facebook share dialog http://s3.amazonaws.com/uso_ss/10985/large.png?1284850755
Until recently, I accomplished this by passing all of my parameters to http://www.facebook.com/connect/prompt_feed.php. Yesterday this broke, and it appears that Facebook is deprecating this sharing method in favor of using their Dialog code. (All of the official FB docs now refer to prompt_feed.php as the "old" way of sharing.)
I found a temporary workaround here that just adds a display=touch variable to the prompt_feed query string. This URL is working for the time being (go ahead and click it!), but I fear that it's a loophole that Facebook will close as soon as they realize it's still available, and I'll be stuck without a way to post stuff to FB.
The current methods of posting to Facebook seem to be 1) using the Dialog URL mentioned above and 2) via Javascript using FB.ui Both of these methods appear to require a Facebook App ID, and when I registered a new FB app for this purpose and tried to use it to create a http://www.facebook.com/dialog/feed request, I got an error because my app doesn't "own" the IMDb page that it's linking to. Any ideas about how to accomplish my purposes going forward?
to "own" the imdb page you just need to set the canvas url to the imdb domain.
you can simply use this url:
http://www.facebook.com/sharer.php?u=http://www.your-url-to-share.com
Just modify or change the http://www.your-url-to-share.com part in the above URL with url of the webpage or article that you want to share on the facebook feeds.
If you use the sharer.php and want text plus a link add the &t={text} to the url. For example:
http://www.facebook.com/sharer.php?u=http://www.your-url-to-share.com&t=text-to-share

Categories