Text and Link sharing by share_open_graph API - facebook

I am getting issue with FB share_open_graph API. I have some text on a page and have one button to share that text and page URL (http://www.example.com?article_id=123).
Clicking share button text and link get share on Facebook users wall. But if user click the post from Facebook wall then link is got update with new parameters "fb_action_ids and fb_action_types".
Updated URL: http://www.example.com?article_id=123&fb_action_ids=422174444504370&fb_action_types=og.shares
Now if user wants to share again those text and page link FB share_open_graph API throws errors
enter image description here
FB.ui({
method: 'share_open_graph',
action_type: 'og.shares',
action_properties: JSON.stringify({
object : {
'og:url': url, // your url to share
'og:title': title,
'og:description': desc
}
})

Related

Using the FB API, can you share a link, but serve an image that is not on the page

I can post a photo IF I had the time to get an app approved. I can share a link that pulls in a photo from THAT page. The goal is to post a link that goes to X, but the image is hosted somewhere else.
Is this possible?
Yes, it's possible by using the JavaScript SDK and the Share Dialog. For example, I can do the following, which shares a link but with a custom image, name and caption. It basically overwrites all the OG data on my page.
function fb_share() {
FB.ui( {
method: 'feed',
name: "Facebook API: Tracking Shares using the JavaScript SDK",
link: "https://www.webniraj.com/2013/05/11/facebook-api-tracking-shares-using-the-javascript-sdk/",
picture: "https://stackexchange.com/users/flair/557969.png",
caption: "Tracking Facebook Shares on your website or application is a useful way of seeing how popular your articles are with your readers. In order to tracking Shares, you must used the Facebook JavaScript SDK."
}, function( response ) {
// do nothing
} );
}
$(document).ready(function(){
$('button.share-btn').on( 'click', fb_share );
});
You can do the same thing in PHP if you have the publish_actions permission approved by Facebook. Both would produce the following result:
Source

Do Users Have To Login Through Facebook For My Custom Like Button To Post To Their Facebook Profile

I want to use a custom like button which uses the og.like action to post to a user's Facebook timeline when they like a post on my website as detailed here. https://developers.facebook.com/docs/opengraph/guides/og.likes
It says they will need to grant my website Publish_Actions in order to do this. Does that mean they have to log into my site using Facebook, or can they authorize it just logging in using my existing login system?
It should be possible without authorization by using FB.ui share:
FB.ui({
method: 'share_open_graph',
action_type: 'og.likes',
action_properties: JSON.stringify({
object:'https://developers.facebook.com/docs/',
})
}, function(response){});
Source: https://developers.facebook.com/docs/sharing/reference/share-dialog

How to change Facebook send dialog name and thumbnail?

so I implemented Facebook send dialog in my Facebook app, but the problem is that it always displays server name and some random thumbnail. I put everything as it shown in Facebook documentation but nothing works.
This is my code:
FB.ui({
method: 'send',
name: 'myName',
picture: 'image/path',
link: 'https://apps.facebook.com/APP_ID/',
});
You should read https://developers.facebook.com/docs/sharing/reference/send-dialog according to that page the parameters you can pass in are: app_id, redirect_uri, display, to, link. Neither name or picture are listed.

How to post a photo to page wall as page's admin role via Graph API

I use node.js to handle Graph API, and post feed, link normally on the Facebook page wall.
But if I post a photo to page, it cannot use page role.
The photo will be posted with my Facebook user, and shown on the other side.
So, how can I post a photo to page wall with page role via Graph API
--
POST https://graph.facebook.com/#{page_id}/photos?access_token=#{access_token}
With Parameters
{
message: 'the message'
url: 'the image url'
}
OR use multipart/form-data
{
message: 'the message'
source: 'post file'
}
same result, help please.
The access token has manage_pages, public_stream permissions.
Useful feed post
POST https://graph.facebook.com/#{page_id}/feed?access_token=#{access_token}
{
message: 'something interesting'
}
this will show on page's wall as page role
If you want to act as the Facebook Page itself, you will need to pass an access token for it. I put details on that in here: https://stackoverflow.com/a/16576107/183880
It's for PHP, but the basic concept should get you where you need to go.

Post image to Facebook Page Timeline via Graph API

I would like to post a photo to the Timeline of a Facebook Page via Graph API. My setup is node-based and written in coffeescript. My current implementation is this (error handling ommited):
sendImageToFacebookTimeline = (user, message, imageURL, callback)->
url = "https://graph.facebook.com/#{pageID}/photos"
params =
access_token: user.accessToken
url: imageURL
message: message
request.post({url: url, qs: params}, (err, res, body)->
body = JSON.parse(body)
callback(body.id)
)
This succesfully posts the photo to my Page. But instead of appearing on the timeline it appears in the "Photos of PAGE".
How can I post to the Timeline?
EDIT:
I found out that by posting to /page_id/feed with option "picture" you can send a photo to Timeline. This shows up the same way as og:image and the view is similar to a link.
EDIT 2:
If you upload to a album, it will show up on Timeline. I have created an album and trying to post to it. But the API doesn't seem to accept URL for source when posting to /album_id/photos.
To post to own Timeline you need to acquire Page access token from /me/accounts and not by getting a user token or exchanging token for a long term token.
With that and album ID you can post to an album, which shows up on the Timeline.