I don't use Facebook, so at a bit of a loss here, as the API documentation doesn't quite answer this, perhaps someone here knows...
Looking at building a Facebook app to assist publishing from a content-driven web app. Obviously we need authorisation via OAuth to publish an app link to a facebook user's wall, but is authorization for everyone viewing the app within Facebook required? We have no interest in making use of the viewer's facebook data, we just want to show them a page.
If they have to authorise the app, then that's a bit of a barrier - but it's not clear if they can just view the app without anything getting in the way.
"is authorization for everyone viewing the app within Facebook required?"
If you mean having your app post a link to their wall, then yes, you will need to ask for their permission to do so. If you mean can other friends can see the post made by your app to an authorized user's feed? No the friends do not need to authorize your app to do that.
But remember Facebook now has the ability for you to specify which groups can see the post. See https://developers.facebook.com/docs/reference/api/user/#posts and read about the privacy field.
Yes, you can show app without any authentication. If you want user to share content then you can do it like this. Code is few months old, so I don't know if that works.
You cannot set custom text/message for the user. This will display popup window where user must confirm sharing/posting to wall.
<div id="fb-root"></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<script type="text/javascript">
FB.init({appId: 'APP_ID', status: true, cookie: true});
function share(object) {
var obj = {
method: 'feed',
link: 'http://apps.facebook.com/your_app_url/',
picture: object.picture,
name: object.name,
caption: object.caption,
description: object.description,
action_links: [
{ text: 'My Cool App', href: 'http://apps.facebook.com/your_app_url/' }
]
};
function callback(response) {
}
FB.ui(obj, callback);
}
</script>
If you're doing a canvas app, you don't need to. You get this generic information in the initial HTTP post:
user A JSON array containing the locale string, country string and the age object (containing the min and max numbers of the age range) for the current user.
algorithm A JSON string containing the mechanism used to sign the request.
issued_at A JSON number containing the Unix timestamp when the request was signed.
You get no actual information about the user, though. You need to authenticate to get that.
Related
I'm using Sitecore Social Connect to log users into my website using Facebook & Twitter. Sitecore's documentation has detailed instructions on how to post to a user's timeline using Marketing Goals, but I'm wondering if there's another way to do this. Is it something I can do directly through the API? Pretty much any other options would be worth exploring. There's not a ton of documentation around this.
Social connected messages must be associated with either content items or marketing goals, but it is possible to trigger a marketing goal using the API:
GoalUtil.RegisterEventParameters("Goal Name", new Dictionary<string,string>());
This fires the goal, and has the additional feature of allowing you to replace tokens in the message text. For example, if you defined a Goal named "Mayor", and create an associated Facebook message with this text: "I've just become mayor of $place.", you can cause this to appear on a user's Facebook wall specific text by doing this:
var tokens = new Dictionary<string, string>();
tokens.Add("place", "New York");
GoalUtil.RegisterEventParameters("Mayor", tokens);
This message will appear on the users wall: "I've just become mayor of New York." Notice that the dollar sign appears in the message, but not in the token key value added to the dictionary. GoalUtil is in the namespace: Sitecore.Social.Core.Publishing.Utils, in the Sitecore.Social.Core.dll.
In addition, when a message is associated with a goal, the following rule is added to the goal:
where true (actions always execute)
post associated messages
You can replace the always true condition with different logic, possibly using Rules Engine conditions you have authored, to restrict messages to meet the required business logic.
We used the facebook js API itself to achieve this:
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
var facebookAppId = '<%=FacebookDefaultAppId %>';
FB.init({ appId: facebookAppId, status: true, cookie: true, xfbml: true });
function openFbPopUp() {
FB.ui({
method: 'feed',
name: 'Your Site Name',
caption: ' ',
link: document.URL, // Current Url
description: $('#quotes').html(),
// Description from the sitecore item which was available in the same page
display: 'popup'
});
return false;
}
</script>
FacebookDefaultAppId - was the app id (Application Id) set in the sitecore item where we set the facebook app details:
Which we get here in facebook for the app created:
Truth be told, this solution has nothing to do with sitecore, but since we manage the app secret key in sitecore, I am pulling it in from there as opposed to saving it some place else too.
This results in the following when the js is triggered (say on button click):
Sitecore Social Connected API was introduced in the 1.3.1 version. The API documentation is available here: http://sdn.sitecore.net/Products/Social%20Connected%20Module/Social%20Connected%201,-d-,3/Documentation.aspx
I have my site qa.carryon.com (this is our test site). I have configured it for facebook login and send invitations. In facebook I have configured SiteURL as 'http://login.qa.carryon.com/gs/'. 'login.qa.carryon.com' is our CNAME and we are using Gigya as social third party.
Login is working fine and when users see the list of facebook friends, user will click on one of them and the facebook send dialog triggers. The link parameter for send dialog is something like this 'http://qa.carryon.com/loyalty/signup?userid=xghdt6ys&username=xyz'.
For this link am i getting the error code 100 link invalid or there is other issue in configuration. I am doing this for first time and i cant understand whats going on. Please help i am stuck with no clue.
I had this issue as well and I was using dynamic querystring parameters on a common URL. It seems you are doing the same.
I fixed the issue by forcing Facebook to scrape the URL before I attempt to send it via the FB UI Send Dialog. Use the FB API to hit graph.facebook.com with the URL posted in the id parameter and a scrape parameter set to true.
Like so:
FB.api('https://graph.facebook.com/', 'post', {
id: '[URL]',
scrape: true
}, function(response) {
FB.ui({
method: 'send',
name: '[name]',
picture: '[Picture URL]',
link: '[URL]',
description: '[description]'
});
});
Also answered here.
Does that help?
If there any way to check in PHP SDK if user can write on specific friend's Wall?
Example:
if ($facebook_can_write_to->'123456789') echo "You can write on this friend's Wall";
Using the FQL table (http://developers.facebook.com/docs/reference/fql/user/) you can check to see if the current user can post to a friends wall by loading up the friend's user information specifically the can_post field.
can_post bool Whether or not the viewer can post to the user's Wall.
According to the documentation you can post on a user friends wall if that user granted you the *publish_stream* permission:
publish_stream
Enables your app to post content, comments, and likes to a user's
stream and to the streams of the user's friends.
There are some cases in which you won't be able to do so, for example if some user blocked your application then I guess it will fail if you try, so you should just check the response you get back from facebook for the api request and see if it worked or not.
Edit
As far as I'm aware you can not ask the api (nor via fql) "can my application post to this users wall", you can only ask "have this user granted my application the publish_stream permission".
If I understand what you want, I might have kind of a solution for you though.
I say show the user the option to post on a friends wall.
When the user chooses this option try to post on the friends wall (and I assume you are using ajax for that call), if it fails return some kind of code, then in the client side check for that code, if it returns use the javascript sdk to open a dialog.
You have two choices for dialogs, you can use the Feed Dialog like this:
var obj = {
method: 'feed',
to: "FRIEND_ID",
name: 'A message',
caption: 'Just trying something',
description: 'This is how to post on a friends wall'
};
FB.ui(obj, function(response) { console.log(response); });
Or you can use the Send Dialog:
FB.ui({
method: 'send',
to: "FRIEND_ID",
name: 'A message',
link: 'LINK_URL',
});
With this one though you have to post a link, I'm not sure if that works for you. After you tried and failed for a user you can save that data and use it later.
Usecase - I have my web application and I want to post some data from my application onto my Facebook wall manually when a user clicks on a Link.
I'm currently using Share Link as follows -
https://www.facebook.com/sharer/sharer.php?u=&t=titleABC" target="_blank">
Share on Facebook
Issue -
I see that a new window opens to post the data. My data also gets posted to my wall, but I want the title to be populated with data from my application rather than asking the user to "Write Something".I want the text box to get populated with the message from the title(t from the url parameter) rather than user editable.
Is there a way to do this.
Sharing your content with Share button is absolutely simple. In my case I did it like this for a button i have in my html with id sharebuttonfacebook
$("#sharebuttonfacebook").click(function() {
var msg = "Hi This is my wonderful website";
FB.ui({method: 'feed',
name: 'MCQ Nation ',
link: 'http://www.mcqnation.com/Trail3/pyramid.php?..dyanmic stuff..' ,
picture: 'http://www.mcqnation.com/Trail3/fbapp2.png',
caption:'CLICK ON THE IMAGE TO GO TO OUR WEBSITE',
description: msg ,
message: 'AAA'});
return false;
});
In addition to this you need to register an app.
Nothing could be simpler.
Just go to http://www.facebook.com/developers/app
and register your new app.
They will give you a simple code that has to be put just after the body which goes like -
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR_APP_ID', // App ID
channelUrl : 'CHANNEL FILE LOCATION', // Channel File This file has just one line which you will find at facebook developers
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
</script>
With these two things in place you can Decide what to share on facebook.
Also in the function we have made above you can substitute whatever variables you like hence make it dynamic. Hope this answers your Question.
PS: If it could get better than this you dont need any permission from the user!
I just can't find out how to do this.
I'm building a website in scala (on google app-engine) and I made a facebook page for it and created a facebook application. All I want to do is to post to my own page's wall. I don't want to use java facebook api, 'cause I think it's way too much to do such a simple thing, but I really can't find a simple way to do so.
Is there a "low level" facebook api?? something simpler that works on posts and gets like twitter api for example?
Or any idea or alternative way to do so will be appreciated.
Thanks!
Facebook has an API that you can use, but it isn't quite as straightforward as the Twitter API. It would be a bit of overkill to write in support, unless perhaps you are prototyping something for someone else to use.
For an individual case, you might be best served by using Posterous- if you setup a Posterous account linked to your Facebook Profile, emailing facebook#posterous.com with the sender set as yourself will likely be the easiest way to post content to your wall. With this, you can use any SMTP email-capable library that supports either HTML emails or attachments. An added bonus is that you can also cross-post to twitter and a number of other places from Posterous by altering the destination Posterous email.
Incidentally, Posterous also has an API too, but I don't remember off the top of my head if you can redirect where posted materials are sent through the API. I've only used it for image uploads, myself.
Here is a strait forward out of the box wall feed example using Javascript SDK
SDK connection, just change the appId to your Applications own ID.
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '135669679827333',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
//channelUrl : 'http://WWW.MYDOMAIN.COM/channel.html', // channel.html file
oauth : true // enable OAuth 2.0
});
if (window!=window.top) {
FB.Canvas.setAutoResize();
}
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
Post Script, notice the to: parameter, change this to the page you wish to post to. You can edit all other fields as needed.
<script language="javascript" type="text/javascript">
//<![CDATA[
function feedthis() {
FB.ui({ method: 'feed',
message: 'Testing Feed',
caption: 'This is the Caption value.',
name: 'Testing JS feed dialog on ShawnsSpace',
link: 'http://shawnsspace.com?ref=link',
to: '391793380398',
description: 'Testing property links, and action links via Feed Dialog Javascript SDK',
picture: 'https://shawnsspace.com/ShawnsSpace.toon.nocolor..png',
properties: [{ text: 'Link Test 1', href: 'http://shawnsspace.com?ref=1'},
{ text: 'Link Test 2', href: 'http://shawnsspace.com?ref=2'},
{ text: 'Link Test 3', href: 'http://shawnsspace.com?ref=3'},
{ text: 'Link Test 4', href: 'http://shawnsspace.com?ref=4'}
],
actions: [
{ name: 'Shawn', link: 'http://ShawnsSpace.com'}
]
});
};
//]]>
</script>
<button onclick="feedthis();">Post to Wall</button>
There are two steps required to do this:
Create a custom Facebook App and add it as a tab to your page
Set this newly added tab as the default when a new user visits your page
Details:
Create a custom Facebook App and add it as a tab to your page
This step is tricky but manageable for an average HTML programmer. To illustrate it best, I will point to a great tutorial on this:
http://how-to-create-facebook-app.koliber.com/
Set the tab as default
As the admin, go to your page
In the upper-right corner click on "Edit Page"
Under the heading "Default Landing Tab", select the tab which
contains the application you created earlier.
Well, I found there is a REST-like api:
This means that our Facebook method calls are made over the internet by sending HTTP GET or POST requests to the Facebook API REST server (http://api.facebook.com/restserver.php) . Nearly any computer language can be used to communicate over HTTP with the REST server.
Documentation here: http://wiki.developers.facebook.com/index.php/API