i want to get album photos so far i have been able to get album info
I am using facebook c# sdk 5.0 for dot net framework 4
code so far is dynamic friends = app.Get("me/albums");
this provides data and we can get everything mentioned here http://developers.facebook.com/docs/reference/api/album/
but i cannot establish connection mentioned for photos
so far i have been able to find this method if there is a good or different approach then please let me know.
//Get the album data
dynamic albums = app.Get("me/albums");
foreach(dynamic albumInfo in albums.data)
{
//Get the Pictures inside the album this gives JASON objects list that has photo attributes
// described here http://developers.facebook.com/docs/reference/api/photo/
dynamic albumsPhotos = app.Get(albumInfo.id +"/photos");
}
Related
In microsoft teams, there is a tab titled "Organization", which shows something like this:
Is there any way I can get this data in C# by using Graph API?
Right now I have
var users = await graphClient.Users.Request().GetAsync();
which returns an array of all users, and each user has their name and job title. This is not enough to make the org chart, because it does not tell how different users relate. What Graph API call do I need to make in order to get the data to make the org chart?
If you are using Microsoft Graph SDK for C#, you can use the code below to get users with the manager:
var usersWithMgr = await graphServiceClient.Users.Request().Expand("manager").GetAsync();
Result:
I found out you can make a graph call to users to get all users in a domain, then foreach user, make a call as listed here: https://learn.microsoft.com/en-us/graph/api/user-list-manager?view=graph-rest-1.0&tabs=csharp
This will get the manager, which can be manipulated into a hierarchical view.
UPDATE:
var users = await graphClient.Users.Request().Expand("manager")
.Select(u => new { u.DisplayName, u.JobTitle, u.AccountEnabled}).GetAsync();
This is my first question, so I want to apologize if I am not doing it correctly.
Description
I am developing a C# mobile application using Visual Studio for Mac, and already installed the LinqToTwitter nuget package (version 4.2.1). I need to retrieve all the tweets from an account (for which I already have the credentials). The code I am using is the following:
var auth = new ApplicationOnlyAuthorizer()
{
CredentialStore = new InMemoryCredentialStore {
ConsumerKey = socialMedia.twt_consumer_key,
ConsumerSecret = socialMedia.twt_consumer_secret
}
};
await auth.AuthorizeAsync();
var ctx = new TwitterContext(auth);
var tweets =
await
(from tweet in ctx.Status
where tweet.Type == StatusType.User &&
tweet.ScreenName == socialMedia.twt_screen_name &&
tweet.Count == 30
select tweet)
.ToListAsync();
List<Tweet> list = (from tweet in tweets
select new Tweet
{
StatusID = tweet.StatusID,
ScreenName = tweet.User.ScreenNameResponse,
Text = tweet.Text,
ImageUrl = tweet.User.ProfileImageUrl,
MediaUrl = tweet?.Entities?.MediaEntities?.FirstOrDefault()?.MediaUrl
})
.ToList();
Problem
After making this call I get a list of tweets returned. All of them are associated to the desired account and contain almost all the necessary information that I will use in the app. The issue occurs when trying to access the MediaEntities; from the total 30 tweets returned, only 2 of them contain information and the majority of them are empty; which is the reason of this line:
MediaUrl = tweet?.Entities?.MediaEntities?.FirstOrDefault()?.MediaUrl
What's been tried
I've been looking for quite some time a solution for this issue, but unfortunately I couldn't find any suitable one.
In twitter documentation I found the following about the Media object:
The entities section will contain a media array
containing a single media object if any media object has been
‘attached’ to the Tweet. If no native media has been attached, there
will be no media array in the entities. For the following reasons the
extended_entities section should be used to process Tweet native
media:
+ Media type will always indicate ‘photo’ even in cases of a video and GIF being attached to Tweet.
+ Even though up to four photos can be attached, only the first one will be listed in the entities section.
(https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/entities-object.html)
So what I first did was to look inside extended entities, but the result was the same (they were empty).
Looking into other posts with similar issues I found the following:
Try adding the tweet_mode=extended parameter to your API call.
(https://twittercommunity.com/t/media-entities-not-showing-on-most-returned-tweets/77375)
So I added the following code to the query:
&& tweet.TweetMode == TweetMode.Extended
But then I got an exception which I didn't manage to resolve:
Captured Exception
My guess is that it has to do with an issue with LinqToTwitter (but can't assure this).
At last I tried including some other lines to the query (which didn't solve the issue):
&& tweet.IncludeEntities == true
&& tweet.IncludeRetweets == true
Questions
Is something wrong in the code? Is the authentication process wrong and it is necessary to include all 4 fields (ConsumerKey, ConsumerSecret, OAuthToken, AccessToken) for what I am trying to achieve? (please note that the connection is successful as the tweet list is returned properly with the exclusion of the media entities).
Maybe I am missing something and the tweets are supposed to be created in a specific way? (By the way, I reviewed the tweets from the account in the twitter page and they all contain media)
The entities section will contain a media array containing a single
media object if any media object has been ‘attached’ to the Tweet
Is the workaround to use TweetMode.Extendend? If so, how could the exception shown above be solved?
Thanks in advance to everyone who will take a look into this question.
Finally after a lot of time struggling with this issue the answer was found with the help of Joe Mayo (GitHub). The solution is:
Update the nuget to the 5.0.0-beta3 version.
Update all dependencies from the nuget (as the above version link suggests).
Add the following properties to the tweet query:
tweet.TweetMode == TweetMode.Extended
tweet.IncludeEntities == true
After this, the media entities are returned successfully; enabling the access to the tweet's attached media.
For more information about what was tried, please follow this link. There, the solution suggested by Joe Mayo (GitHub) is explained. Thanks to everyone who took the time to review and help with this issue.
I was using the Facebook Public API Feed for the longest time and since they deprecated it I've been trying to find a replacement method in C#.
I am able to get my page posts but any post that contains images I only get the message and no images. After spending the past weekend trying to find a way I am desperate to know if anyone has had any success in getting full page post content from the Facebook C# SDK library.
Here is what I have and it works for getting the posts but they do not contain any images.
var fb = new FacebookClient
{
AppId = ConfigurationManager.AppSettings.Get("FacebookAppID"),
AppSecret = ConfigurationManager.AppSettings.Get("FacebookAppSecret"),
AccessToken = ConfigurationManager.AppSettings.Get("FacebookAccessToken")
};
var pageFeed = string.Format("/v2.4/{0}/feed", _facebookPageId);
dynamic response = fb.Get(pageFeed);
Since the upgrade in Graph API v2.4. Only a limited set of data is sent via FB unless specifically requested. You should pass the fields parameter with the keyword of data which you would like to retrieve.
A list of keyword is available here
In your case, the request statement would be:
var pageFeed = string.Format("/v2.4/{0}/feed?fields=id,message,picture", _facebookPageId);
To get all pictures from a post: replace picture with attachments, as picture will return the very first picture linked to the post.
var pageFeed = string.Format("/v2.4/{0}/feed?fields=id,message,attachments", _facebookPageId);
I need to get the Video Ids from a YouTube Playlist.
e.g.: Thats our demo playlist: http://www.youtube.com/playlist?list=PL8B03F998924DA45B
That's my c# code:
SyndicationFeed feed = await client.RetrieveFeedAsync("https://gdata.youtube.com/feeds/api/playlists/PL8B03F998924DA45B?v=2");
I then can not find the IDs of the single videos from the playlist in my feed object. Any Ideas?
I suggest you to use Data API v3. Data API is the one that reflects playlists in YouTube and highly supported.
In v3, you will do a playlistItems->list call with setting the playlistId.
In the response, if the playlist item is a video, you can get videoId from either snippet.resourceId.videoId or contentDetails.videoId
You can find C# examples here.
Is it possible to get all photos by a persons name through the Picasa Web Albums Data API?
All examples I can find, shows how to get photos by an albumid.
You can request a list of the most recent photos, with a very high value for max-results.
I'm not sure if you are using the .NET API Client Library, but if so, an example is here:
http://code.google.com/apis/picasaweb/docs/1.0/developers_guide_dotnet.html#ListRecentPhotos
Use query.NumberToRetrieve to set the value for max-results.
If you are not using the .NET Client Library, an example using HTTP protocol can be found here:
http://code.google.com/apis/picasaweb/docs/2.0/developers_guide_protocol.html#ListRecentPhotos
You can retrieve facial recognition data from the Picasa Web API through a (currently) undocumented API URL that is used by the Picasa desktop application. More info here:
http://klick.com/pharma/blog/2011/09/retrieving-face-tag-data-from-the-picasa-web-api/
by setting "default" that mean retrieving current user with that code you can retrive the user photos in specific album
PhotoQuery query = new PhotoQuery(PicasaQuery.CreatePicasaUri("default", albumId));
PicasaFeed feed = picasaService.Query(query);
foreach (var entry in feed.Entries)
{
PhotoAccessor photoAccessor = new PhotoAccessor((PicasaEntry)entry);
Photo photo = new Photo();
photo.Title = photoAccessor.PhotoTitle;
photo.Summary = photoAccessor.PhotoSummary;
photo.MediaUri = entry.Content.AbsoluteUri;
photo.Id = photoAccessor.Id;
photo.AlbumId = photoAccessor.AlbumId;
photos.Add(photo);
}
If you know the subjectid then using an RSS link you can get a feed of ALL images for that user regardless of albums. The link is:
http://picasaweb.google.com/data/feed/base/user/PICASA_USERNAME?alt=rss&kind=photo&subjectids=SOME_BIG_LONG_STRING_OF_CHARACTERS
Also, you can find the subjectids by going to each person on PWA and clicking the RSS link at the bottom of the page.
I am stil trying to find a way to get all subjectids without a manual lookup.
Source: http://credentiality2.blogspot.com/2010/02/picasa-gdata-api-and-face-recognition.html