We are working on updating our site to use the v2 facebook API. With v1, we did the sharing as follows:
FB.ui({
method: 'feed',
name: $('title').val(),
display: 'popup',
link: url,
picture: fbImg,
caption: 'Compute information about '+$("#i").val()+'.'})
});
We used some javascript to dynamically pick the thumbnail image and would store it in fbImg.
With v2, it appears that there is no longer a simple picture parameter. Instead it seems that we must define a static image to be used with the og:image meta tag.
We've found that a dynamic image can be used using method share_open_graph:
FB.ui({
method: 'share_open_graph',
action_type: 'og.shares',
action_properties: JSON.stringify({
object: 'http://' + longUrl,
image: imageVariable
})}, function(response){});
This is v2 compliant, but the action type og.shares was just a guess, which oddly seems to work. og_shares is not documented, and a google search for it turns up nothing. This makes us very hesitant to just use that code in production..
Is there a "correct" way to dynamically pick an image for a facebook share using the v2 api?
Related
I have a facebook app, and I am able to share links, and image for this link, on FB, using FB.ui.
The point is, depending for the FB account who is sharing the link, I can get big image, or small one.
This is a real pain, because if I configure and send big image, on the accounts which uses small one, the image is cropped, and also on the other way.
I am sending, as far as I know, all known parameters for FB, but the result is the same.
FB.ui({
method: 'share_open_graph',
action_type: 'og.shares',
action_properties: JSON.stringify({
object: {
'og:title': title,
'og:description': description,
'og:url': invitationLink,
'og:image:url': imgPath,
'og:image:width': imgWidth,
'og:image:height': imgHeight,
'og:image:alt': 'refer a friend by lottoland'
}
})
});
What could be wrong here? How can I "force" facebook to always use same type of image?
Thanks anyone for the support.
I would like to enable users to share a certain feed with dynamically generated pictures. This means that the picture url is always a new one.
However, it seems that the picture Facebook is using is not that from the URL but always (an old) one from the cache.
The URL is something like http://www.domain.com/facebook/unique-picture.png
How is it possible to turn off the caching?
function shareMessage(link) {
alert(link);
FB.ui(
{
method: 'feed',
name: link,
link: 'link',
picture: link,
caption: link,
description: "description",
message: ''
});
}
I'm trying to do a basic facebook wall post with an embedded flash object based on the following documentation:
https://developers.facebook.com/docs/reference/dialogs/feed/
I'd like to do this using just a direct URL, like (note parameters get encoded):
https://www.facebook.com/dialog/feed?
app_id=SOME_APP_ID&
link=http://www.myregisteredfbdomain.com/someurl&
picture=http://www.myregisteredfbdomain.com/cfg/media/imagelink.png&
name=Flash%20Test&
caption=Just%20a%20test&
description=A%20Description&
redirect_uri=http://www.myregisteredfbdomain.com/someurl&
source=http://www.myregisteredfbdomain.com/facebook/aflashfile.swf
Although I've also tried it using javascript, with the same result:
<script>
FB.init({appId: SOME_APP_ID, status: true, cookie: true});
function postToFeed() {
var obj = {
method: 'feed',
redirect_uri: 'http://www.myregisteredfbdomain.com/someurl',
link: 'http://www.myregisteredfbdomain.com/someurl',
picture: 'http://www.myregisteredfbdomain.com/cfg/media/imagelink.png',
name: 'Flash Test',
description: 'A Description',
source: 'http://www.myregisteredfbdomain.com/facebook/aflashfile.swf'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
</script>
When I do the post under my development fb account, the post shows up fine, and I can click on the icon which displays the flash correctly.
However when I post under my own personal fb account, the post shows with the image only, but no flash activation when I click it - it just goes to the link/redirect link I defined.
Can anyone give me any pointers as to why this might be the case?
Found out why - It's because I'm accessing the post to my personal account through a https connection, which doesn't show the flash - it's linked via a http connection.
As we all know (http://developers.facebook.com/docs/share/) Facebook has deprecated the share function. However, the about to go live app center apparently is using the very same share UI.
Is there a way for the regular folks to access the same UI from JS SDK provided by Facebook? Assuming, it is not the same as described in https://developers.facebook.com/docs/share/.
Although it's deprecated, you can still use it in the way it was used before.
Facebook Share Documentation
However, It's not a good idea to use this. Instead, you can just create a facebook app and use FB.ui to perform this action:
Example Code:
<script>
FB.init({appId: "<your_app_id>", status: truey, cookie: true});
function postToFeed() {
FB.ui({
method: 'feed',
link: '<the_link>',
name: '<name>',
caption: '<caption>',
description: '<description>'
});
}
</script>
thank you for your time first.
I have a very simple question here,but I can't figure it out for an entire day.
I built an facebook app which just post a message to wall,the problem is it requires user install the app first then request permission,that means 2 clicks,I don't like.
I saw somebody merged the 2 steps into 1,how did he get it?
http://www.permadi.com/tutorial/facebook-js-graph-api-post-to-wall/index2.html
And this one is mine
http://2.youpiaoma.com/fb_api/post2wall.html
Here is the snap of the install page
2.youpiaoma.com/a.JPG
The issue is that you're using the new enhanced auth dialog in your app, and for some reason it is not honoring the &perms=publish_stream parameter. Since the blog is older, some of the code is out of date with the more current ways of doing things.
I think you may benefit from using the new feed dialog instead: https://developers.facebook.com/docs/reference/dialogs/feed/
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Using Dialogs to interact with users.'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
But if you want to continue using the old code, I would suggest the following changes:
you can use the FB.login() call instead of building the string yourself. That way the API is responsible for making the login box correct.
specify a channelUrl in your FB.init() call too. See: http://developers.facebook.com/docs/reference/javascript/FB.init/