Facebook's sharer.php - default view - javascript

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.

Related

loading more items without scrolling nor pressing 'see more' like in facebook with JS

How can I load more page contenant in facebook, without pressing 'see more' button using javascript ?
for example in facebook groups, if I want to view all the group members I shall go to members tab and press 'see more' until the end of the members..
I'm working on creating a browser extension that will allow me to extract some info from the members page, I know that I can extract names from facebook graph api, but I'm looking for extracting more info such who added those members.. by scanning the source code of that page.
So now I'm facing 'how to automatically load the whole members page contenant ?'
You could easily trigger click events on the button like this:
<button id='load-more-button'>Load More</button>
<script type='text/javascript'>
$('#load-more-button').click();
</script>
If you want to repeat the proccess untill its end i guess this would do the job:
var interval = setInterval(function(){
$("#load-more-button").click();
},3000);

How to change the login button to logout when user loggs in via iframe form

I have not been able to find a close enough answer to this question to find a solution that works.
I am working in a custom website, and at various points, the user login status is checked before the user can proceed with the action. If they are not logged in, they are asked to login first, and then they are allowed to proceed. To keep the user experience clean, most of this is done through in-page pop-ups that contain an iframe.
The login functionality is working perfectly, but when the user is done with the action and closes the window, the "login" button still shows, making it appear that they have not logged in. They actually have to refresh the page to see their login status. I would prefer, however, that the login status to appear seamless as well.
Currently, I have the login link contained in a div in the parent page:
<div class="top_nav">
<div class="contest_buttons">
<div class="c_button bkg_gray c_bottom w_quarter" id="#login_tab">
<?php echo showif(!empty($_SESSION['userID']),'
Logout','
Login'); ?>
</div>
<div class="c_button bkg_gray c_bottom w_quarter" id="#profile_tab">
<?php echo showif(!empty($_SESSION['userID']),'
My Profile','
Register'); ?>
</div>
<div class="c_button bkg_gray c_bottom w_half">
Wayne Daily News
</div>
</div>
</div>
The closest I have gotten to anything that could work is:
$('#login_tab', window.parent.document).html('Logout');
I'm not really sure where to go from there.
At the least, I want the #login_tab to read "Logout" when login has completed, but being able to update the #profile_tab to read "My Profile" would be great as well.
I am a PHP programmer that is just dabbling in JS and jQuery so far, so even pointing me in the right direction might be helpful. :)
I found something that shows some promise. It's not as clean as I would like, but this code seems like it might hold a solution...
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("a[rel^='prettyPhoto']").prettyPhoto(
{
callback: function(){
document.location.reload(true);
}
})
});
</script>
Because I am using PrettyPhoto to create the popups and iframes, I may be able to integrate a method or call another script that would handle my needs and it would occur on the event that the window is closed by the user.
What would it take to make something work this way?
There are many ways you could accomplish this.
You could have the login button on the page(s) inside iframe.?
or You could create the html for the 2 buttons inside php vars and call through said button links.?
However I would try using JS & CSS, check out this simple example of Button state switching.
http://css-tricks.com/swapping-out-text-five-different-ways/
After reading your latest comments, Maybe try to create login buttons depending on session state.
eg:
if( !isset($_SESSION) ){
//echo login links here
}
also don't forget to use
session_start();
in the page shown in iframe.

Why does Facebook change the "FB.ui - picture" when the share is resharing on facebook itself?

I use following sourcecode to share a Feed on Facebook.
Explanation:
I have many pictures and each picture has a own ShareButton with an onclick which starts the shareonfb().
And the first share works very well, it shares the picture, but if somebody clicks onto the share, it's opens the gallery which consist the picture(because, if i use for 'link' the direct picture-url, it would only open the picture and the person would not see the homepage).
Problem:
If i try to reshare(to click on the share button in facebook at this share), facebook doesn't use the content of this variables. It uses the og:XXXX meta-tags which are at my website(where it goes by the 'link' url). Because of that, there is a other Picture and Text ...(the share-content has changed).
So, I don't understand why it does that ... I can only specify the datas/variables for 1 post/share ... that makes no sense. Then I could work directly with the og:xxx meta-tags. BUT I don't want that, because the pictures itself has no own html-page where i could place my own meta-tags(i show them "directly"(with fancybox). (I wanted to change the meta-tags by javascript, but I read here on stackoverflow that the facebook crawler doesn't run JS.)
So, for what is the function to specific this datas?, and how get I Facebook to don't change it?
MfG Torben K
function shareonfb() {
var FB_ui_var = {
fb_method : 'feed',
fb_name : 'Name of picture',
fb_link : 'http://mysite.de/the_gallery_which_consist_the_picture027.html',
fb_caption : 'Description caption',
fb_picture : 'http://mysite.de/picture027.jpg',
fb_description : 'Descriton Text',
}
FB.ui({
method: FB_ui_var.fb_method,
name: FB_ui_var.fb_name,
link: FB_ui_var.fb_link,
caption: FB_ui_var.fb_caption,
picture: FB_ui_var.fb_picture,
description: FB_ui_var.fb_description,
}, function(response){});
}
That´s how it is, the share dialog does not allow dynamic content (anymore), you ALWAYS need a page with Open Graph tags and the dialog only takes the URL as parameter.
One way to solve this is to use a PHP file with a parameter/id for getting separate Open Graph tags and a JavaScript redirection to the main page. The Facebook crawler does not run JavaScript, so it can get the Open Graph tags.
Btw, the feed dialog is deprecated, you should use the FB.ui share dialog instead.

How to connect facebook send button with facebook UI?

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.

FB.api post to FB wall from "app page"

i got a little problem with facebook javascript api.
I have app and page for this app.
I have added this app to the page and i got "app inside Pages with Like button on the top, you should know".
like here
Then, using FB.api i'm tried to post message + logo + description + link to the wall on clicking button in this app.
i'm tried to make it looks like this:
but that's was what i saw after clicking "post to fb" button in my app
From all properties what i set, it took only "message". Picture was taken from "icon for this app", name was taken from "app page name", another properties were ignored.
code:
FB.api('/me/feed', 'post',{
message : 'Some message',
link : 'http://link.com',
picture : 'http://link.com/image.jpg',
name : 'App name',
description : 'App description.'
},
function(response) {
console.log(response)
});
i have valid access_token and 'publish_stream' permission, but the same piece of code post
various posts to facebook. result like on the first image from simple app and second image from the page app.
does anyone know how to post to facebook wall messages like on the first image from the app inside page ?
Post wieving depends from "link" attr in the FB.api method, if it reference to the simple app - post will be like on the first image and if link will reference to the page app - post will look like on the second image.
so as i need result like on the first image - we are just put link to the simple app in the "link" attr and then in the app we will check: "are we on the page app or not, if not - redirect to the app page".

Categories