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".
Related
I am developing my first app using angular.js (v 1.6.3) and I am stuck on a very basic problem. I have created a list page for "User Group", and on this list I have a Edit button. On click event of this edit button, I want to redirect the record id to edit page.
Below is code for my button:
<button data-ng-click="editUserGroup(userGroup.id)">✎Edit</button>
Below is the code for editUserGroup
$scope.editUserGroup = function(userGroupId) {
//$location.path("/userGroup.html").search({c:'edit', id:userGroupId});
//$scope.$apply();
$window.location.href = './userGroup.html#/?c=edit&id='+userGroupId;
}
In short, I want to redirect to edit page and also need to pass 2 parameters,
?c=edit&id=<actual id here>
As you can see in my above code, $location.path() not working as it is not reloading new page, rather changing the URL only like <Some URL>/listUserGroup.html#!/userGroup.html?c=edit&id=1. If I use $window.location.href, I can redirect to new page but #/ is getting HTML encoded like below
<Some URL>/userGroup.html#!#%2F%3Fc=edit&id=1
How should I redirect to new page and pass both the parameters using angular.js?
So, taking hint from comments, I used window.location to redirect the page to next, and used window.sessionStorage to store the data I want to send to next page.
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.
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
I implemented a FB Invite your Friends Button on one of my Facebook Apps. - the invite works well - the invited user gets the right message but when he clicks on it - it just lead to nowhere (a blank page).
How can I direct where this invite should lead to ?
Here is my invite code :
function invitefriends() {
FB.ui({method: 'apprequests',message: 'Einladen',data: '128', title: 'Lade Deine Freunde ein'}, requestCallback);
}
function requestCallback(response) {
//
}
Sorry - I searched already for a long time via google etc. but nothing solved my problem :(
edit
I found the problem - but now another problem occured.
The problem was that my index.php on my CANVAS URL was blank and only my tab.php (PAGE TAB URL) was the content. But since I am using a LIKE Gate (where people have to LIKE my page before they can use the app) - the invite leads always to the PLEASE LIKE site :/
is there still any chance I can choose where the invite should lead ?
No. You can not change where the invite sends the users. You can however have a simple redirect on your canvas page -
<script type="text/javascript">
top.location.href = "YOUR_TAB_PAGE_URL";
</script>
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.