Hello i always use the function() below to invite people to an app:
facebookConnectPlugin.showDialog(
{
method: 'apprequests',
message: 'Check out Givvia!'
},
function(response) {
log(JSON.stringify(response));
httpService.logAppRequest(response);
},
function() {
log('Could not send Message');
}
);
Unfortunately, this function not work anymore for normal App which is NOT A GAME.
I was looking around and i found the these code:
var fbOptions={
url: "URL LINK",
picture:"PICTURE LINK"
};
facebookConnectPlugin.appInvite(fbOptions,
function(postId){
console.log("success");
},
function(error){
console.log("failure");
console.log(error);
alert(JSON.stringify(error));
}
);
Now, i'm able to invite friends but i do not get the response i was get with 'aprrequest'. here i get the refer and the receiver ID of facebook. do anyone know how to get these information with appInvite?
Related
I'm doing a hybrid app using Ionic framework.
I want to implement a facebook event system to attend some events. I have this:
ngFB.api(
'/666945880120392/attending',
'GET',
{},
function(response) {
// Insert your code here
}
);
and I have ngFB in my app.js file like this:
ngFB.init({appId: '[APP_ID]'});
The error I have is:
openfb.js:256 GET https://graph.facebook.comundefined/?access_token=undefined net::ERR_NAME_NOT_RESOLVED
I was looking for a solution but no answer. I also try in the developer facebook console and the answer is correct:
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=666945880120392%2Fattending&version=v2.7
What it's happening? Thanks!
EDIT 1
Thanks to #e666 I did now this
ngFB.api({
method: 'GET',
path: '/666945880120392/attending'
}).then(function(response) {
console.log(response);
}).catch(function(error) {
console.error(error);
});
And the error now is that if I'm logged with an account always the return in the event is:
Object {data: Array[1], paging: Object}
And inside data is the name of another person, the unique person that is attending to the event and no the person who is logged with the access token.
Thanks!
EDIT 2
I opened another question because this is not the result than I hope, I need to go to an event, no to get the list of the people that goes to the event.
I have this now:
ngFB.api(
"/666945880120392/attending",
function (response) {
if (response && !response.error) {
console.dir(response);
}
}
);
the access_token is ok, and the response is
openfb.js:256 GET https://graph.facebook.comundefined/?access_token=EAABlK6y7pOUBAN3CPWdZB5FL…LCpXL9Bd3ELHQZAA6EJc6cCheAxUUnL59ZCZAf7aROCapJxiu991fxjDkxmMO651rfuREwZDZD net::ERR_NAME_NOT_RESOLVED
In the page of facebook https://developers.facebook.com/tools/explorer/?method=POST&path=666945880120392%2Fattending&version=v2.5
The response is
{
"error": {
"message": "(#299) Requires extended permission: rsvp_event",
"type": "OAuthException",
"code": 299,
"fbtrace_id": "G7HFJ48pbkx"
}
}
But I have this permission. Can someone help me please?
First, the path is undefined because you don't use correctly the method api. That is how you need to use it :
ngFB.api({
method: 'GET',
path: '/666945880120392/attending'
}).then(function(response) {
console.log(response);
}).catch(function(error) {
console.error(error);
});
Furthermore, you have undefined in access_token. As I looked in the library code, I am not sure that you can use this library without login as a user to have an access_token.
To have an access_token you need to use this function :
ngFB.login({scope: 'email'}).then(function(response) {
console.log('Access token' + response.authResponse.accessToken);
}).catch(function(error) {
console.error(error);
});
The access_token will then be automatically attached to request that you make with OpenFB.
You can find more complete examples of how to use the library is the github here : https://github.com/ccoenraets/OpenFB/blob/master/indexng.html
I am trying to add a tab trought the facebook js api, and it fails:
Login with permissions:
FB.login(function(response) {
console.log(response);
}, {
scope: 'publish_actions, manage_pages'
});
FB.login(function(response) {console.log(response);
}, {perms:'read_stream,publish_stream,offline_access'});
reading pages to get token:
FB.api(
"/me/accounts",
function (response) {
if (response && !response.error) {
console.log(response)
}
}
);
adding a tab, for example, these two methods:
a.
FB.api(
"/{page_id}/tabs/",
"POST",
{
"app_id": "{app_id}",
access_token: "{token}"
},
function (response) {
console.log(response)
}
);
I get response:
Object {success: true}
b. tried directly:
jimdoGen002.getJSON('https://graph.facebook.com/{page_id}/tabs?app_id={app_id}&access_token=token&callback=?', function(r){console.log(r)})
I get response, array with the tabs the user page has, but without my new tab.
going to the user page - no new tab.
My questions:
what am I missing? why do I get sucess but cant get the tab?
if its because the review of "manage_pages" by facebook is not complete yet - why do I get success?
if the above - how can I test manage pages BEFORE I post it to facebook review?
Can I add a tab WITHOUT an app inside? just an iframe url?
Thanks in advance,
Lior.
(to make it all simple:)
FB.api(
"/me/accounts",
function (response) {
var token = response.data[0].access_token;
var id = response.data[0].id;
console.log(response.data[0].name);
FB.api(
id + '/tabs',
"POST",
{
"app_id": {app_id},
"access_token": token
},
function (response) {
console.log(response);
FB.api(
id + '/tabs/{app_id}',
function (response) {
console.log(response)
},
{
access_token: token
},
function(response) {
console.log(response)
}
);
}
);
}
);
result:
my page
Object {success: true}
Object {data: Array[2]} - none is my app.
I am building a custom multi friend selector in order to send posts to friend's walls on Facebook based on this tutorial
https://developers.facebook.com/docs/guides/games/custom-muti-friend-selector/
I have been able to load my list of friends and create a CSV list of people I want to post to but the last step of opening the feed dialog is failing and I don't understand why. The dialog does not open.
this is my sendRequest function
var sendUIDs = '';
$('.cbFriendId').each(function(index){
if($(this).prop('checked') == true){
var addId = $(this).attr('value');
sendUIDs += addId + ',';
}
});
console.log(sendUIDs);
openSendDialog(sendUIDs);
}
function openSendDialog(sendUIDs){
console.log('open send dialog');
FB.ui({
method: 'feed',
to: sendUIDs,
link: 'http://www.mydomain.com',
display: 'iframe',
message: 'Hello from My Domain',
name: 'Click to view my app',
caption: 'Hello my app'
},
function (response) {
if (response) {
alert('Post was published.');
console.log('Post was published.');
} else {
alert('Post was not published.');
console.log('Post was not published.');
}
}
);
}
The last console log entry is 'open send dialog'. I get no errors in IE9 dev tools but I do get an 'Unsafe Javascript attempt to access frame ...' error in chrome.
just for sanity sake here is my graph init
window.fbAsyncInit = function () {
FB.init({
appId: '462750593765445', // App ID
channelUrl: '//www.mydomain.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
frictionlessRequests: false
});
};
Also I should mention that the app is in sandbox mode.
Thanks for the help
What you're trying to do is called Send Dialog, So you need to change your method from feed to send and it should work.
Check out their docs for more information: https://developers.facebook.com/docs/reference/dialogs/send/
I need to create a button to submit a comment on Face Book wall.
I am using MVC in Sencha touch and in my controller I use a function as
facebookComment: function()
{
--------
}
This function is to be called when a button is pressed.
Can any body please throw some light on how to go about this?
i am using following code to post on friends wall see if it is useful to you or not
var postParams = {
method: 'stream.publish'
, target_id: friend_id
, display: 'popup'
, message: message
, user_message_prompt: "Post message!"
}
FB.api(postParams, function(response) {
if(response.error_code || !response) {
to handle error
}
});
or refer this link https://developers.facebook.com/docs/reference/rest/stream.publish/
Well, first you should already be using the Javascript SDK. Then just issue a HTTP POST request to the feed connection of the current user using the FB.api() method with the message field set to your comment:
var body = comment_var;
FB.api('/me/feed', 'post', { message: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
Obviously, should be taking care of the user login status (maybe using the method FB.getLoginStatus()).
Is there a way of building a custom request dialog, and sending the selected userid(s), the app request. I don't want to be using the multi-friend selector form.
This function here should provide you the ability to send a request to a single person.
<script>
function sendFriendInvite(message,title,to,data){
FB.ui({method: 'apprequests',
to: to,
message: message,
title: title,
data: data
},
function(response) {
if (response && response.request_ids) {
//Sent!
} else {
//Not Sent
}
});
}
</script>
<a onclick="sendFriendInvite('Here is an invite','Send to Invite to Friend', 123456);">Send request to friend 123456</a>