I need to write a program that will retrieve facebook insights from a page I'm the administrator of. I have to use a console app because there are other things that I must do later with the data. My problem is with logging in automatically. I created a facebook application but after doing some research I saw that for reading a facebook page insights I must first login to obtain an access token, which would allow me to obtain a manage_page permission.
So my question is how do I obtain user access token with the console app in C#?
var fb = new FacebookClient();
but then what?
The best way to learn how to code an Insights application is to use the Getting Started wizard. You can find Getting Started session in https://developers.facebook.com/apps/[app_id]/marketing-api/
Basically you can pick metrics and the wizard will generate a working code for you. (It is only generating Java code for now)
Also if you don't really wants to code, you may try the new product we just released called Facebook Ads Manager for Excel. It allows you to download Insights data into Excel directly. More info:
https://www.facebook.com/business/m/facebook-ads-manager-for-excel
Related
Hi everyone I have a problem I wanna create app for generate account google drive with api google drive and I don't know how can I login with account from application not navigator C# windows form.
enter image description here
and how can i edit this credential with exist user
Try following these steps:
https://learn.microsoft.com/en-us/aspnet/core/security/authentication/social/google-logins?view=aspnetcore-3.1
I have used those steps and worked perfectly for me. You don't have a choice than to be redirected to the Google authentication page.
After entering your Google credentials, you are redirected back to the your site.
My understanding is that you are trying to use Google Drive API from a console application. Or for that matter a fully desktop application.
Take one thing in consideration, if you don't use Service account you must let the user authenticate to google and allow your application to work in his/her behalf. There is no way around this.
What you can do is after the user has already signed in, is to save the tokens and refresh them whenever necessary.
Of course OAuth may be complicated, but you use the .NET library everything will be managed for you. And you can look at a real example in the .NET Drive Quickstart
My company has an internal application where I need to pull/display pictures of all the employees from office 365 with out user intervention.
From what I read online I think I need to call Microsoft graph getphoto API in daemon application to achieve this as per this link (https://developer.microsoft.com/en-us/graph/docs/authorization/app_only).
Will this be a right approach? If yes please point me to any C# sample codes related to this.
Appreciate your responses.
Yes, this is exactly the type of application you will want to build. App-only (machine-to-machine) authentication should be used anytime you don't need a user present to execute functionality.
You can take a look at the ASP.NET Core App Only sample to get a sense of how to register and set up your app to use app-only authentication. The sample goes on to use this access token to set up webhooks, but you can replace this logic with your custom code. You will want to select the scope User.ReadBasic.All to have access to users' profile photos.
The C# Facebook SDK host on github allows Windows Store apps to login to their account via the app and post e.g. statuses or app related content through the app, however there are still some concepts that I don't understand.
Firstly, is it only possible to perform facebook related tasks after I have logged in for the current session. Can I not login in once (say, when I first download an app) and then have the app retain my settings. Then, whenever I want to post some content via my app and can just do it straight away, instead of having to sign in again (in the same or another session)
I was hoping that in my app I would be able to login in via an option in the settings charm which would navigate to my HomePage.xaml, and then I would be able to save that login state for multiple sessions. Currently I have this first bit running (though not completely, I can login but that's it right now), but how would I/can I automatically post content in future sessions without having to log in again?
Secondly, many apps that integrate with Facebook apps, that allow the user to post data stored in their local app or web user account via the Facebook app counterpart. How is this performed?
Say I have a class MyDataClass which contains properties DataTitle, DataItem1 and DataItem2. I would want to be able to send this to my wall, and have it display as an ordinary post (examples for this sort of functionality include things like ask.fm and formspring.) Would I then even be able to store this data via my Facebook app, and be able to send it to the users friends should they wish?
I would appreciate it if someone could explain whether these things to me. I've been search for a couple of days now and haven't answered these bigger questions.
Facebook C# SDK can be used via NuGet or you can get library from GitHub. When any user logs in via Facebook, the login result returns "Access Token". It is unique among all the Facebook users. You can save that access token in individual user's LocalSetting. Local setting documentation can be found here. Local setting can be used in this way.
//create instance of local settings
var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
// Create a setting
localSettings.Values["FB_Access_Token"] = "THIS_IS_DUMMY_ACCESS_TOKEN";
// Read data from a setting
var objFbAccessToken = localSettings.Values["FB_Access_Token"];
if (objFbAccessToken == null)
{
// No data
// Do relogin of Facebook and save new facebook token
}
else
{
// Access user's Facebook data with help of Facebook C# SDK and Access Token
}
// Delete a setting
localSettings.Values.Remove("objFbAccessToken");
See this for extending access token.
Get long live access token from Facebook
I'm trying to authenticate users in a winrt metro app using Azure ACS.
I've set up a relying party in azure with a simple webtoken.
on windows 8 I've installed the azure toolkit. When I created a new project from the winrt cloud (notifications + acs) template and I fill in all necessary parameters I can run the app, I get the live ID login screen but when I enter my credentials I get a message saying "We can't load that page".
Can anyone help me with this?
With "I fill in all necessary parameters" I'm assuming you mean the Configuration.xml file contains the necessary information to your ACS namespace etc...
Now, filling in this information and configuring ACS isn't enough to make the sample work. If you take a closer look at the Configuration.xml file, you'll see the following elements:
<!--Relying party return Url. The bouncer service url that will parse the token from ACS.-->
<ReturnUrl>https://127.0.0.1/bouncer</ReturnUrl>
<!--Authentication End Url. The bouncer service url used to validate if the authentication process is done.-->
<EndUrl>https://127.0.0.1/bouncer/end</EndUrl>
These are URLs from an Azure application you'll also need to run in order for the sample to work. In the toolkit you'll find the following directory:
WATWindows.Setup.v1.2.4\Samples\Notifications.CSharp\Notifications.Backend
To be able to run the sample application you'll need to start this backend application first.
And did you already run the SetupSample.cmd script in the WATWindows.Setup.v1.2.4\Samples\Notifications.CSharp directory?
i am developing a notification service in c# for our web site. its windows service no ui (asp.net / winform). This service will run on certain time and post something on users wall. i use social plug-in in our web site where user can grant required permission. Based on this i have few question
1) is there any c# library or sdk available for Facebook.
2) what information i have to store in order to access facebook offline.
i hope my question is clear. thanks for any help.
Update 1: i really need help on this. thanks once again.
There is a facebook API that can be used, http://developers.facebook.com/
You can't access facebook offline? I mean, if you wanted to save current information while online and then re-access the old information while offline that is possible just by saving the webpages, but you cannot access any new information. so your not really accessing facebook..
You'll need the user to log in, and there's a permission you can request that makes the session you get permanent. You'll have to have some kind of installer or something that will have the user log in, grant that permission, and then you'll save that access token. UI-wise, look at digsby, and notice how they make you log in to facebook the first time you link your facebook account.
i found this one and its helpful
http://blog.theunical.com/facebook-integration/simple-5-steps-to-publish-on-a-facebook-wall-using-dotnet-c/