After loading FB UI this is my Code:
<div class="fb-send" data-href="https://www.gmx.de" data-colorscheme="light"></div>
Now I want to add 2 different users (prefilled in the dialog).
There is code like this:
FB.ui({
method: "send",
link: "http://www.google.com/",
to: ["zuck","dmp"]
},
function(response) { alert(response); }
);
But how can I connect the Facebook-Button with this code?!
You are using Send Button and Send Dialog both- which isnt required! Both do almost the same thing.
I think you thought that you could pre-fill the recipients using the to parameter - that's right BUT you cannot add more than one recipient. You can use to with one user-id only.
On click of a button / html element- call FB.ui method, this will open the send dialog.
Related
I have problem with Facebook ui share dialog (visit https://developers.facebook.com/docs/sharing/reference/share-dialog).
I'm using this code for share a page (where is setting the correct og metatags) with this Javascript Code:
FB.ui({
method: 'share',
href: '{{ user_share_path }}'
}, function(response){
if (response && !response.error_code) {
alert('Thank you');
} else {
alert('Ops! Something goes wrong');
}
});
When the user shares link with the Javascript Facebook code the result in user wall is a very poor content element with just the title. If the user copy manually the link "user_share_path" to their wall everything is fine and every og metatag in the page is showed in post.
I've also tried to use share_open_graph method but I had the same effects.
Here there is a screenshot with the two post, once with JS the other manually posted:
Any idea why? Thanks
I've read the documentation about like actions, but can't get this to work.
I'm trying to get a status if a logged in user is liking an URL with the Javascript SDK. But doesn't get any progress.
How could this be done?
Below I use this code to "like" an URL.
FB.api(
'me/og.likes',
'post',
{
object: liked_url
},
function(response) {
// handle the response
}
);
HTML
<div class="like_button">Like This</div>
And when I click the above like button it likes the URL and add a class to the above div, but I want to be able to refresh the page and still have the "liked"-class on the objects that are liked.
I might have picked you up wrong but you could try using this to create your like button
//Update:
With help I managed to catch some errors which fixed the token issue. I've updated the code to reflect that. The code still doesn't produce an event on the timeline though so I'm leaving the question up.
Original question:
I'm trying to build a simple script using the Open Graph API that will push a link to a visited page (containing a movie) to Facebook, once the visitor hits the page.
I'm not using a custom action and object, but the standard Watch action (https://developers.facebook.com/docs/opengraph/video/) and Video.movie object.
I came up with this based on FB's example code:
<!-- first login-button with scope publish_actions: -->
<fb:login-button show-faces="false" width="200" max-rows="1" scope="publish_actions" ></fb:login-button>
<!-- Then script that should push update to timeline: -->
<script type="text/javascript">
function fbPublish(){
FB.api(
'/me/video.watches',
'post',
{ 'video.movie': '<?php the_permalink(); ?>',
'access_token': 'blablabla' },
function(response) {
if (!response || response.error) {
alert('Nope.');
} else {
alert('Yes.'); // any stuff
}
});
}
This triggers the alert 'Nope'.
I have added the Watch action through curl.
Any ideas as to what could be going on?
You still need to FB.login before you can automatically post to the user's timeline.
FB.login(function(response) {
// Post the action
}, {scope: 'publish_actions'});
While I didn't check the validity of your actual code to post the action, you problem is that before you can do this, you'll need the user's permission. The publish_actions permission is the one you'll need but I think its already included in new Auth Dialogs. Just leave it there to be sure.
Do the FB.login code first, you'll get a popup "Allow" dialog, after that, is the time you can freely post in the user's wall. It's a part of the security, Facebook users wouldnt want you posting on their timeline without them knowing.
I'm using the Facebook Send Dialog to send messages to friends. As documented here: https://developers.facebook.com/docs/reference/dialogs/send/ and am using a link like the one in Facebook's example:
https://www.facebook.com/dialog/send?app_id=123050457758183&name=People%20Argue%20Just%20to%20Win&link=http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html&redirect_uri=http://www.example.com/response
On the page I have specified as the redirect_uri I am displaying text saying: "Your message has been sent". However I've realised that you see this page even if you've clicked cancel in the Facebook dialog.
Is there any way to determine whether save or cancel has been clicked?
Update: I've found a workaround using the FB.ui method which solves the immediate issue I was having. I would still be interested to know if anyone has a better solution using a Send Dialog link like the one above.
I've found a work around by using Facebook's Javascript SDK's FB.ui method.
FB.ui({
method: 'send',
name: 'People Argue Just to Win',
link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html,
display: 'popup'
});
N.B. display must be set to popup for this to work!
As it does not require a redirect_uri, the issue of knowing whether save or cancel has been clicked is not an issue. If however you do wish to know this, you can access a response object:
FB.ui({
method: 'send',
name: 'People Argue Just to Win',
link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html,
display: 'popup'
},
function(response) {
if (response){
// save has been clicked
} else {
// cancel has been clicked
}
});
Small complement to Andy's response:
the response-object does not give much info about what has been sent, actually (returns [] in console), but the mere EXISTENCE of the reponse object indicates the "SEND" button has been pressed
FB.ui(obj, function (param) {
if (param) {
// The "SEND" button has been pressed
}
else{
// The "Cancel" button has been pressed
}
I'm using sharer.php to share an item to the user's wall.
The facebook sharer has 2 views:
Post to profile (default view) : alt text http://devgator.com/images/post_to_profile.png
And when you click on "send as a Message instead you get :
alt text http://devgator.com/images/send_as_msg.png
What I'm trying to do is to have the 2nd view (send a message) as the default one.
So when the user clicks 'Share this', it would show him directly the "send a message" view.
Is that even possible using facebook? or anything else? maybe executing js code after the popups opens ?
Thanks.
Facebook just released a new "send" button to go with the "like" button.
This button allows you to send message directly to your friends ..
Here is an example :
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:send href="example.com" font=""></fb:send>
See documentation : http://developers.facebook.com/docs/reference/plugins/send/
I think it's a solution for your problem ?
It's undocumented, but you can pass &mode=message&to=<user_id> to default to send message with sharer.php. Note: the like and/or send buttons are recommended.