Is there any way to send apprequests if your application is a website?
I reported a bug on facebook http://developers.facebook.com/bugs/182553325173000 but I do not know if this is possible or not
yes you can do this by adding the JS API,
before <body> add:
<script type="text/javascript">
function inviteFriends(){
var receiverUserIds = FB.ui({
method : 'apprequests',
message: 'YOUR CUSTOM MESSAGE',
},
function(receiverUserIds) {
console.log("IDS : " + receiverUserIds.request_ids);
}
);
}
</script>
after the <body> include the API (asynchronous method):
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR APP ID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
oauth : true //enables OAuth 2.0
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
and call it:
or
You can do that with the Javascript SDK
it is in the documentation:
https://developers.facebook.com/docs/reference/dialogs/requests/
It's possible, as the other answers have shown, but the user will be brought to your canvas app when they accept the requests
Related
I am having a hybrid mobile application(should work in android and ios). In which I need to post on facebook wall from my application. Please note its a hybrib app, so I am not supposed to use any java or c code.
I tried the following method , its working in simulator , but not in actual device. Please help me.
<script>
window.fbAsyncInit = function() {
FB.init({
appId : ' my appID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
<script type="text/javascript">
$(document).ready(function(){
$('#share_button').live('click', function(e){
e.preventDefault();
FB.ui(
{
method: 'feed',
name: 'HyperArts Blog',
link: 'http://hyperarts.com/blog',
picture: 'http://www.hyperarts.com/_img/TabPress-LOGO-Home.png',
caption: 'I love HyperArts tutorials',
description: 'The HyperArts Blog provides tutorials for all things Facebook',
message: ''
});
});
});
</script>
Thanks
I ran into this. your:
document.location.protocol
which is suppose to pull in the FB SDK is actually "file:///" and thats what gets fed into the url for that FB JS library.
Manually specify http:// or https://
This didnt work for me either on safari webView on IOS so i had to hit the endpoints manually using AJAX.
I want to load facebook api ( javascript SDK) synchronously. I have seen this code on facebook developers.
<div id="fb-root"></div>
<script src="//connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : 'YOUR_APP_ID',
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
</script>
and also on reference to another link
http://www.masteringapi.com/tutorials/facebook-javascript-sdk-best-practices/58/
is is mentioned that "But you need to make sure you don’t define FB in your own JS code or libraries!"...............
I am confused ....!
Please help me....
What you are doing looks fine.
The instruction that you've seen, "But you need to make sure you don’t define FB in your own JS code or libraries!" is simply a warning to not declare a variable named FB in your application, or you will hide the Facebook SDK.
In your code, on the very next line, you could begin making calls with FB.api or any of the other methods.
Does that help?
Add the below code after opening html tag
<div id="fb-root">
</div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: 'Your APP ID',
status: true, // check login status
cookie: true, // enable cookies to allow server to access session
xfbml: true, // parse XFBML
oauth: true
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
} ());
</script>
This code will load the javascript SDK asynchronously.
I am using the code below to send an app request to someone.
It works fine; it displays in Facebook notification.
when I click that notification, it redirects to the facebook app page.
I'm unable to make it redirect to the page which exists list of facbook app requests.
How do I make it redirect there?
is there any need to do changes in my facebook app setting ?
<div id="fb-root"></div>
<script>
function FacebookIframeAuthenticator(){
window.fbAsyncInit = function() {
FB.init({
appId: '123456789',
status: true,
logging: false,
cookie: false,
xfbml: true
});
FB.Canvas.setSize({height: 2000});
FB.Canvas.scrollTo(0,0);
FB.Canvas.setAutoResize();
};
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);
}
new FacebookIframeAuthenticator();
function sendInvReq ( friendUid, event ){
FB.ui({
method: 'apprequests',
message: 'I\'d like you to join my professional network on SITE NAME .- DB',
to: friendUid,
data: ''
}
, function(r){
if (r != null && typeof(r) != 'undefined'){
if (r.request_ids){
FB.api('/me/apprequests/?request_ids='+toString(request_ids));
$.ajax({
url: 'http://exapmple.com',
cache:false,
type:'POST',
data:({requestIds: r.request_ids.join(','), x_csrf: csrf}),
dataType: 'json',
complete: function(transport){}
});
}
}
}
);
}
</script>
in your developers page (https://developers.facebook.com/apps/your_app_id/advanced) you must change your application advanced settings "Upgrade to Requests 2.0" to disable
If I understood your question right: you can't control the notification url. It will always automatically redirect to your app url with one or more request_ids as paramter. The only possibility to redirect to your prefered destination is to look for this parameter and react properly.
I use old FB API in my project.
For showing FB avatar I use facebooker gem in my Rails app. I user facebooker method "fb_profile_pic(owner, {:linked => false, "facebook-logo" => :true}". He generate this FBML:
<fb:profile-pic facebook-logo="true" height="73" linked="false" size="square" uid="1440313044" width="73" style="width: 73px; height: 73px; " class=" fb_profile_pic_rendered"><img src="http://external.ak.fbcdn.net/safe_image.php?d=d5eee08e09b7573d93b61f82ac11feda&url=http%3A%2F%2Fprofile.ak.fbcdn.net%2Fhprofile-ak-snc4%2F41642_1440313044_4069_q.jpg&logo&v=5" alt="Shaliko Usubov" title="Shaliko Usubov" style="width:73px;height:73px;" class=""></fb:profile-pic>
If I display this avatar on the page which is available at https protocol - getting error
"The page at https://my_domain.com/ displayed insecure content from http://external.ak.fbcdn.net/safe_image.php?..."
How can I get FB avatar with HTTPS protocol?
/* ATTENTION BELOW */ says if your your app https then fb javascript libary will be https.
You may check in your code
window.fbAsyncInit = function () {
FB.init({ appId: /*123456789*/', status: true, cookie: false, xfbml: true });
};
(function () {
var e = document.createElement('script'); e.async = true;
/* ATTENTION BELOW */
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
} ());
I'm trying to fb:login-button work for mobile web, a la: http://developers.facebook.com/docs/guides/mobile/
However, I'm not sure where to add this code: &display=touch
My FBML is the standard:
<fb:login-button autologoutlink='true' perms='user_about_me,email'></fb:login-button>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({ appId: 'XXXXXXX', status: true, cookie: true, xfbml: true });
FB.Event.subscribe('auth.login', function() {
location.href = "....";
});
};
(function() {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
} ());
</script>
Any ideas?
I'm pretty certain you're not able to use the FBML tags for mobile web applications. At least, they won't accept the display=touch argument.
It means you'll need to use the slightly more complex OAuth implementation that they describe on http://developers.facebook.com/docs/guides/mobile/
It kinda makes sense if you think about it. The FBML tags generally rely on popups or overlays, which you can't really be certain will be compatible with all mobile browsers. The OAuth implementation takes you off to a FB page and returns you back to your host site for authentication and authorisation.