How to post on my facebook page from my website using Facebook App keys created from my facebook account? - asp.net

Below is the code i am using to achieve this functionality, and i have successfully posted it to my facebook wall from my website but i am not able to post to my facebook page?
How can i get page access token using FaceBookClient() in c# SDK?
var client = new FacebookClient();
dynamic token = client.Get("oauth/access_token", new
{
client_id = ConfigurationManager.AppSettings["FacebookAPI"].ToString(),
client_secret = ConfigurationManager.AppSettings["FacebookAPIKey"].ToString(),
grant_type = "client_credentials"
});
client.AccessToken = token.access_token;
dynamic parameters = new ExpandoObject();
parameters.title = detail.Title;
parameters.message = GetDescription(detail.Description, detail.Content);
parameters.link = "http://test.com/blog" + detail.RelativeLink;//HttpContext.Current.Request.IsLocal ? "http://test.com/blog" + detail.RelativeLink : HttpContext.Current.Request.Url.Authority + "" + detail.RelativeLink;
var result = client.Post(ConfigurationManager.AppSettings["FacebookPageID"].ToString() + "/feed", parameters);

Please read the docs at
https://developers.facebook.com/docs/graph-api/reference/v2.3/page/feed#publish
It's clear that you can't use an App Access Token for posting to a Page, because a Post always needs to be related to a profile.
A user access token with publish_actions permission can be used to publish new posts on behalf of that person. Posts will appear in the voice of the user.
A page access token with publish_pages permission can be used to publish new posts on behalf of that page. Posts will appear in the voice of the page.

Related

AcquireTokenAsync returning null for User.DisplayableId

I’m developing a Xamarin app that uses Azure AD B2C and I’m having some trouble getting data from any of the providers.
Even though I have LinkedIn, Google, Microsoft, Facebook, and Twitter setup as Identity Providers, and they appear to be configured properly, the only data returned is User.IdentityProvider. Both User.Name and User.DisplayableId are null. This happens for all of the providers.
Here is my call to AcquireTokenAsync:
var result = await App.AuthenticationClient.AcquireTokenAsync(Constants.Scopes, user, UIBehavior.SelectAccount, string.Empty, null, Constants.Authority, App.UiParent);
I have my application claims selected:
The login succeeds on every provider, but I don't get email addresses back like I need.
With help from a friend, I discovered that while the values in the User field are returned using Azure AD, the response from an Azure AD B2C call populates the IdToken field instead.
A bit more sleuthing turned up this to be a serialized JwtSecurityToken object. That led me to the following code:
var displayableId = ""; // result.User.DisplayableId;
var token = new JwtSecurityToken(result.IdToken);
foreach (var claim in token.Claims)
{
if (claim.Type == "emails")
{
displayableId = claim.Value;
}
}
Now displayableId contains the user's email address.

Xamarin Azure Facebook get user info

I've been searching on the best way to get information my azure auth from facebook.
My app is getting the authentication and the id of the user! I am not sure what code I need next in order to get the information.
So far I have this
if (authenticated)
{
var client = new HttpClient();
var fbUser = await client.GetAsync(Appurl+".auth/me");
var response = await fbUser.Content.ReadAsStringAsync();
var jo = JObject.Parse(response);
var userName = jo["'typ':'user_id'"].ToString();
}
So far all the answers have left me clueless
I just need this to return name email and other Items I want.
I am sure this is an Json Parsing the wrong issue but I am not sure.
Please help!!!
I just need this to return name email and other Items I want. I am sure this is an Json Parsing the wrong issue but I am not sure.
If you visit https://yourmobileapp .azurewebsites.net/.auth/me from browser, and login with your FaceBook account. Then you could get the Json structs as following. It is a JArray . So please have a try to use following code, it works correctly on my side.
var ja = JArray.Parse(response);
var id = ja[0]["user_id"];
Before that we need to add email scope on the Azure portal, about how to add email scope, please refer to the screenshot.

MailChimp.Net User is not subscribed

I'm trying to call MailChimp Subscribe with MailChimp.Net NuGet package to add user to list in MailChimp.
The request is performed with success as far as I can see from MailChimp dashboard but the user is not subscribed in the list.
Did anyone faced such issue?
var myMergeVars = new MergeVar();
myMergeVars.Add("FNAME", "Testy");
myMergeVars.Add("LNAME", "Testerson");
var mc = new MailChimpManager("MYKEY");
// Create the email parameter
var email = new EmailParameter()
{
Email = "test.spektor#gmail.com"
};
EmailParameter results = mc.Subscribe("LISTID", email);
The request should be made with doubleOptIn: false option, otherwise user will receive an email with confirmation on his email box.
var result = mc.Subscribe(listId, emailParameter, myMergeVars, doubleOptIn: false, updateExisting: true);

Can I use Firebase simple login to access Twitter API?

It's easy to get the simple login working with Twitter, and that's a big bonus, but I was wondering whether it's possible to then take those authentication credentials and post a tweet, get a list of people they're following, generally use the full Twitter 1.1 API. I.e. can I get hold of the access token key and secret?
Thanks,
Dave.
The Firebase Simple Login JavaScript client now returns both the Twitter access token and access token secret in the response payload from Twitter authentication.
You can access each of these via the user object, under the attributes accessToken and accessTokenSecret as shown below:
var firebaseRef = new Firebase('https://<MY-FIREBASE-NAME>.firebaseIO.com');
var authClient = new FirebaseAuthClient(firebaseRef, function(error, user) {
if (user) {
var accessToken = user.accessToken,
accessTokenSecret = user.accessTokenSecret;
}
});
...
// Sample jQuery click event.
$myButton.on('click', function(event) {
authClient.login('twitter');
});

Get Google analytics data using Oauth token?

Here I am using asp.net web to display Google analytic data. I am successfully able to get access token using oauth2.0. Using access token I am also get account information.
Here I want to get Google analytic data using access token. Please share link with me to get data using access token.
I have seen following code
http://code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/Analytics_DataFeed_Sample/dataFeed.cs
But don't want to use it because here I have to pass user name and password:
private const String CLIENT_USERNAME = "INSERT_LOGIN_EMAIL_HERE";
private const String CLIENT_PASS = "INSERT_PASSWORD_HERE";
Let me know any way to get analytic data using access token.
After long work will get success.....
Here is Oauth playground made by Google developer from you can test your data
https://code.google.com/oauthplayground/
I just Oauth 2.0 for retrieve access token information after that I am using following URL for getting analytic information.
https://developers.google.com/analytics/devguides/reporting/core/v2/gdataReferenceDataFeed
you need to pass access token with your URL ie :
https://www.googleapis.com/analytics/v2.4/data?ids=ga:12345&metrics=ga:visitors,ga:bounces&start-date=2012-07-01&end-date=2012-07-25&access_token=ya29.AHES6ZTzNR6n6FVcmY8uar6izjP9UGeHYNO5nUR7yU2bBqM
Best of luck Enjoy coding..
You can try with following code
string ClientId = "CLIENTID"
string ClientSecret = "CLIENTSECRET"
var Client = new NativeApplicationClient(GoogleAuthenticationServer.Description, ClientId, ClientSecret);
var Auth = new OAuth2Authenticator<NativeApplicationClient>(Client, Authenticate);
var Service = new AnalyticsService(Auth);
var Request = Service.Data.Ga.Get("profileID", StartDate, EndDate, "Matrix");
Request.MaxResults = 1000;
Request.Dimensions = "Dimensions";
var Result = Request.Fetch();

Resources