Using tweetsharp to pull data for a specific user: I would like to get the numbers of retweet (RT or Retweet) and the numbers of mentioning (#).
Could you help me? Thanks.
The current version of TweetSharp, version 2.0, has methods that map directly to the Twitter API.
Assuming you have the oAuth tokens for a user you can use methods like
.ListRetweetsOfMyTweets(...)
.ListTweetsMentioningMe(...)
If you don't have access to a user's profile, you can still do a search for that user using the standard search query syntax.
.Search("to:JohnDoe" ... )
.Search("from:JohnDoe" ... )
Both should get you the details you're looking for.
Related
I've asked the question below a couple weeks ago and I didn't get a working answer. Or maybe just not suitable for my case.
C# Microsoft Authentication Get logged user from controller
So I thought maybe I wasn't asking the right question. What i'm trying to do is create an app which has a C# Web API 2 backend and an Angular 2 frontend. Now, I want that my authentication be using people's Microsoft Account which means this will be an external authentication.
What's the best way of doing this? It would be very much appreciated if you can give a link on a blog or article that explain what I'm looking for. On my link above I've used msal.js and so far it was working fine for me until I had to get the logged user's details. It was possible from Angular's side but I want to do it in Web API so it is more secured.
Thanks in advance!
If you are using OpenId, you have claims that are returned when user is authorized. I am assuming you are using Azure B2C for authorization in which case you can select clams that will be returned as part of token.
For example, if you want to fetch user id:
var userId = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier")?.Value;
Email:
string userName = ClaimsPrincipal.Current.Claims.Where(x => x.Type == "emails").FirstOrDefault()?.Value;
It depends what claims your authorization has returned, easiest way would be to put breakpoint on
ClaimsPrincipal.Current
and inspect it, it should return list of claims.
From your code in the previous post, it looks like you need to read from the ClaimsPrincipal instead. ClaimsPrincipal is the implementation of IPrincipal when you use OAuthBearerTokens, so of course you can get the username from CurrentPrincipal.Current.Identity
From this documentation
https://msdn.microsoft.com/en-us/library/system.security.claims.claimsprincipal(v=vs.110).aspx
https://learn.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-devquickstarts-api-dotnet
public IEnumerable<Models.Task> Get()
{
var user = ClaimsPrincipal.Current;
...
}
i do with this example
https://github.com/Azure-Samples/active-directory-b2c-javascript-angular2.4-spa
and it work well
I am trying to use my Bot in Microsoft Teams and I have an issue when obtaining the username of each specific user that is using the Bot. A static variable cannot be used since there is only one server and multiple users. I am using this as a reference. Is there any way that I can make use of so that I can get each user's Username?
Please note that when a user interacts with your bot, you will receive the name in the From section of the payload. We will also be adding user name in the Roster retrieval functionality so you can retrieve all team member names along with their UIDs.
In general, if you want to store names for future messages (e.g. push messages vs response), you'd need to use something like Bot Framework's user data store or for more robust support, something like Azure's Table storage.
I just used the AuthResult class to get the user details. The following is the code that I write whenever I want to display the Username.
AuthResult authResult; context.UserData.TryGetValue(ContextConstants.AuthResultKey, out authResult);
And obtain the Username using authResult.
i.e. authResult.UserName
I want to get the user profile data on connect to twitter. I managed to connect and get the access token and access token secret using Tweetsharp Lib. But trying to get the user profile throw an error.
So I want to use the Rest Api and just get the info my self.
I would like to see an example of how to pass the access token and or access token secret. Anybody can help me out please?
I am the developer of Tweetinvi which is a library similar to Tweetsharp but that is maintained and up to date.
You can get a user profile using the following code :
TwitterCredentials.SetCredentials("Access_Token", "Access_Token_Secret", "Consumer_Key", "Consumer_Secret");
var user = User.GetUserFromScreenName("<username>");
I hope this can help you with your code.
Cheers,
Linvi
i have tried to get facebook group id (gid) by it's url using C#, with no luck.
I have looked over the facebook graph tables, tried PHP, FQL queries, and even tried P3P to get the feed itself of the group page (To get the 'cid' value) - But again - with no luck, I'm getting a token successfully using facebook SDK but I dont understand how to use it to get the group id or the group source code (which always returns the login page), can you help ?
You can fetch the username from the url- string after last /. You can find how to do that. Then simply use the Search API.
You'll be needing a valid user access token with the API call-
/search?q={group-username}&type=group
Example: https://graph.facebook.com/search?q=progressivenagars&type=group&access_token={access-token}
Is there any way we can get posts, status of Facebook to show in our application based on some Keywords or GEO location. I have done it for Twitter using developer account where I used to apply some token keys and gets the result in json format.
Is there any similar way to get posts from Facebook developer account?
You can use the Search API to search based on keywords. Like this:
https://graph.facebook.com/search?q=football&access_token={ACCESS_TOKEN}
To search for objects near a geographical location, use type=location and add the center and distance parameters: /search?type=location¢er=37.76,-122.427&distance=1000
Here's more detail: http://api-portal.anypoint.mulesoft.com/facebook/api/facebook-graph-api/docs/reference/search