How can I disable my App from account with using sdk? - facebook

I created App which add infomation about read articles in my site to timetable.
How can I disable my app from users account with using facebook sdk?
E.g. User click a button on my site and App disabled from users account.

You can do something like:
FB.api("me/permissions", "delete", function(response) {
console.log("Application should now be invalidated, response: ", response);
});

Related

Facebook login and share not working in Chrome extension because of app domain

I'm new to creating extensions so please bear with me.I'm trying to create an extension that shares the current page URL via Facebook. I followed the instructions Facebook developers site and created a project but i don't know what to put up as the app domain because local host works but chrome-extension://"id" doesn't.
On clicking share button, Error appears"Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings."
What do I put as the app domain and url?
I had the same problem. This is my solution:
Turn on Embedded Browser OAuth Login in facebook login settings (https://developers.facebook.com/apps/ -> choose your app -> Add product)
Implement manually login flow (https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow). Open oauth url in new tab, listen on changes and than when tab update to success page get from url access token, save token to storage and remove tab.
User facebook graph api (https://developers.facebook.com/docs/graph-api)
Use chrome.identity api to avoid protocol issue. It's looks like:
let options = {
interactive: true,
url: 'https://www.facebook.com/dialog/oauth?' +
stringifyQuery(Object.assign({
app_id: 'your app id here',
redirect_uri: `https://${chrome.runtime.id}.chromiumapp.org/provider_cb`,
response_type: 'token',
access_type: 'online',
}))
};
chrome.identity.launchWebAuthFlow(options, function (redirectUri) {
if (chrome.runtime.lastError) {
callback(new Error((chrome.runtime.lastError as string)));
return;
}
const response = parseUrl(redirectUri);
access_token = response[`#access_token`];
callback(null, access_token);
});

facebook social share need to be login

I'm using facebook social share, calling facebook SDK as following.
var data = { app_id: "myappid123"
caption: "caption"
description: "description"
href: "http%3A%2F%2Fwww.mySite.info%2Fblog%2Fpost"
method: "share"
name: "name"
picture: "http://my.png"
redirect_uri: "http://www.mySite.info/"
}
FB.ui(data, function (response) {
});
However I noticed i have to login as my app_id's facebook account so I could share, if I'm not login to facebook as my app_id's account I can't share.
Do I missing some other authentication by doing this way?
The most likely reason is your facebook app is in developers mode. Check your app setting if it shows something like following
App in developer mode
Then you need to make it public by clicking the question mark at the end of developer mode message, provide contact email address and making it public. After that you can login with any facebook account to share.

Cannot list Ad Accounts in facebook app

I'm developing a pure-html/js web application (actually I'm using AngularJS; with "pure" I mean: I'm not using any server side technology) which uses a Facebook-Connect button like this:
<fb:login-button max_rows="1" size="xlarge" scope="email,public_profile,ads_management" show_faces="false" auto_logout_link="false"></fb:login-button>
Such button asks for permission: ads_management and basic user data. I'm testing ad-management functionality.
However, I ask two queries to facebook inside a controller:
$scope.fetchData = function() {
FB.api('/me', function(response){
$scope.$apply(function(){
console.log("InApp::fetchData()");
console.log(response);
console.log("~InApp::fetchData()")
});
});
};
$scope.fetchAccounts = function() {
FB.api('/me/adaccounts', function(response){
$scope.$apply(function(){
console.log("InApp::fetchAccounts()");
console.log(response);
console.log("~InApp::fetchAccounts()");
});
});
};
$scope.fetchAccountData = function(account_id) {
};
$scope.fetchData();
$scope.fetchAccounts();
For narrow-purposes I just printed the contents of a controller. Assume such controller exists, requires the person is logged in Facebook, and the user is currently logged in.
My Issues are:
The Login button does not update the page when I login. This is because no onlogin= was put. Question: How can I assign such attribute in an Angular way? (i.e. the handler coming from the scope).
$scope.fetchData is successfully executed. However, $scope.fetchAccounts is not. I'm asking this because I included the ads_management permission in the button. Question: What am I missing? (error: code: 10
message: "(#10) You do not have sufficient permissions to perform this action"
type: "OAuthException"). Edit - Additional notes: I deauthorized the application in my account, and reauthorized it: It never asks me the ads_management permission in the popup dialog.
The first question, no idea. The second question, your app is not whitelisted for Ads API usage. Look into the Ads APi documentation on how to request access.

How to setup Facebook App Request from Unity with Prime31 Social combo plugin?

my problem is this, when the user is asked to select friends from the list and click on Send I receive a Success state from callback but no request is reached from the people selected in the list.
My setup is this:
- my app is a native app for iOS and Android made in Unity
- my app is registered in Facebook developer portal as Game/Puzzle, I set up bundle id, package name, display name and namespace
- my app is not yet published
- I configured the Prime31 Facebook plugin with the appId given from Facebook and Display Name
I send my request like this:
public void AskLifesOnFacebook()
{
var parameters = new Dictionary<string, string>
{
//{ "app_id", "#######my_app_id_number####" },
{ "method", "apprequests" },
{ "title", "My request title" },
{ "message", "My request text" }
};
FacebookCombo.showDialog("apprequests", parameters);
}
But still the friends selector is shown up correctly on an overlay windows, I select friends and send the request but no request is received.
Am I missing something in the configuration of my app on Facebook? Do I need to pass some kind of certification?
From the same app the stream.publish is working correctly and I can publish on user walls.
The setup with Prime31 plugin and the call are correct!
You have to enable "Single Sign On" and "Deep Linking" in Facebook app parameters and add a valid itunes ID for your app (while testing you can put any valid ID, but you should create a itunes connect entry for your app and get the final ID).
When your app is a native iOS app, the users see the notifications only through the Facebook iOS app, so they are guarantee they can open iTunes or run the game.
Global notifications instead (ej: regular browser on PC) are seen if the app is in a Facebook Canvas.

Can't send FB Notifications with new API

Really need some help with this one!
I'm trying to send notifications from a canvas app using the new notifications API but I keep getting the following exception:
OAuthException: (#200) Only web canvas apps can send app notifications
However, the app IS loaded in the Facebook canvas -- I'm making an ajax call to my server when the user takes a particular action which triggers the notification POST request. The user has also authorized the app.
This is the code I'm using:
$graphUrl = $user_id . "/notifications";
$params = array( "access_token" => $admintoken,
"href" => $link,
"template" => "string of text < 180 chars"
);
try {
$result = $facebook->_graph($graphUrl, 'POST', $params);
} catch (Exception $e){
echo $e;
}
I just ran into this too and this is how I solved it, but this may not be relevant to you as you seem certain yours is a Canvas app. Mine is an app that mostly runs off Facebook, but has Facebook integration hooks that means users can authorise my Facebook App and then receive updates about interesting events via the Facebook framework.
I went to edit my App settings in the Facebook Developers app, look on the Settings->Basic page near the bottom. I only had "Website With Facebook Login" checked. I checked "App on Facebook" and this gave me a "Canvas Page" and various other settings. With these filled in and saved, the POST to uid/notifications worked immediately.
Incidentally, going to apps.facebook.com/myappnamehere fails because it redirects to https and the request to my site fails because my SSL isn't set up right, but this didn't prevent notifications being sent under that apps credentials.
Recently, I was facing this same issue and I found that Facebook Web Games are formally known as Facebook Canvas.
So, Just create an Facebook game configuration under Settings->Basic page (You will see add button at the bottom of this page) and your API will start sending notifications.
1:\ Go to developer.facebook.com
2:\ Go to your app Settings \ Basic
3:\ Add new platform from plus at button bottom of the page
4:\ Choose Facebook Canvas
now you may need to fill form with your url
That's it