Get the List of all Flikr PhotoSets using Flikr.net API - c#

I am trying to add the name of all photosets into a list box.I have the Token and a Valid Flickr Object.How can i do this in c#.In the standard Flikr API
flickr.photosets.getList
is used but how can i achieve this in .net

Ripped from here
Flickr Library in C#
The last few days I've been working on a sample C# library to access Flickr pictures using Flickr's own API. This library is a light-weight C# class that provides two basic features: (1) retrieve the list of photosets in your account and (2) retrieve information about the photos in a photoset.
Using this class you can retrieve the photosets in your Flickr account and display them in a combobox with a few lines of code like these:
Flickr flickr = new Flickr("YourApiKey", "YourUserID");
List<PhotoSetInfo > photosets = flickr.GetPhotoSets();
cboPhotoSets.DataSource = photosets;
cboPhotoSets.DataTextField = "Title";
cboPhotoSets.DataValueField = "PhotoSetID";
cboPhotoSets.DataBind();
Once you select a photoset you can retrieve information about the photos inside it (like title and URL) with the following code. In this example I am binding the list of photos to an ASP.NET datalist control to display them:
Flickr flickr = new Flickr("YourApiKey", "YourUserID");
List<PhotoInfo> photos = flickr.GetPhotosInSet(cboPhotoSets.SelectedValue);
listPhotos.DataSource = photos;
listPhotos.DataBind();
lblPhotosMsg.Text = (photos.Count == 0) ? "No photos in this photoset" : "";
The Flickr API supports multiple requests and response formats. I am using the REST format for requests and responses in my FlickrLib library. A typicall Flickr REST request looks like this:
http://api.flickr.com/services/rest/?method=methodName&parameter1=value1&parameter2=value2
where methodName is the name of the method to call, for example flickr.photosets.getList to return a list of photosets.
REST responses that Flickr provide are XML documents with the pertinent information for the request. For the flickr.photosets.getList method the reponse would be an XML document with a photosets node and several photoset children nodes. These XML responses are very easy to parse with LINQ to XML and turn them into C# strong-typed objects (like PhotoSetInfo and PhotoInfo) which then can be bound to .NET classes. That's exactly what the FlickrLib library does, it provides a wrapper to the Flickr API functionality so that you can easily consume it from your .NET applications.
References
You can download the C# source code for this class from http://hectorcorrea.com/downloads/FlickrLibDemo.zip
For information about the Flick API visit http://www.flickr.com/services/api/ there is a lot of information there on what the API provides and how to use it. There are tons of Flickr features that the API provide that you might find useful and that my little class does not expose.
You will need to obtain an API key from Flickr in order to use their API through this class or any other class. The API key is free but it is needed so that Flickr can prevent a single user from submitting too many requests to their site and take it down.
Posted on 11/30/2008 12:27:00 PM Perma Link

Related

how to do API calls of Kentico using ASP.NET MVC?

I'm struggling with API calls of Kentico forms using ASP.NET MVC, so that I can use AngularJS to display the return data (JSON format).
Specifically, my client is using Kentico on their server to create data using "Forms" on Kentico and I want to get the records stored in these forms via API calls using ASP.NET MVC. What I'm thinking is that in the general section of the "Forms", I see the "Form code name" showing that "Code name is a string identifier of the object that can be used by developers in API calls or URLs". But it seems to be there's no good example of it on internet. Keep trying to search it but no luck. I also tried to access data directly in SQL Server in which kentico stores the data. But the table's name that Kentico uses in SQL Server to store the data is different from the ones in "Forms" or "Custom tables" in Kentico.
Hope someone can show me how to do it and I really appreciate it. Thanks in advance.
There is a very good example in the official documentation of Kentico.
Please note that Forms have been renamed a few times in the past (they were called BizForms and On-Line forms) that's the reason why the code below references CMS.OnlineForms and uses BizFormInfoProvider. It might also very well be the reason why you didn't find any good example :)
The example below shows how to retrieve Form's definition (metadata), get all the data and iterate through it.
using CMS.OnlineForms;
using CMS.DataEngine;
using CMS.SiteProvider;
using CMS.Helpers;
...
// Gets the form info object for the 'ContactUs' form
BizFormInfo formObject = BizFormInfoProvider.GetBizFormInfo("ContactUs", SiteContext.CurrentSiteID);
// Gets the class name of the 'ContactUs' form
DataClassInfo formClass = DataClassInfoProvider.GetDataClassInfo(formObject.FormClassID);
string className = formClass.ClassName;
// Loads the form's data
ObjectQuery<BizFormItem> data = BizFormItemProvider.GetItems(className);
// Checks whether the form contains any records
if (!DataHelper.DataSourceIsEmpty(data))
{
// Loops through the form's data records
foreach (BizFormItem item in data)
{
string firstNameFieldValue = item.GetStringValue("FirstName", "");
string lastNameFieldValue = item.GetStringValue("LastName", "");
// Perform any required logic with the form field values
// Variable representing a custom value that you want to save into the form data
object customFieldValue;
// Programatically assigns and saves a value for the form record's 'CustomField' field
item.SetValue("CustomField", customFieldValue);
item.SubmitChanges(false);
}
}
UPDATE:
The example above assumes that you're using the API from within the running Kentico instance. If you want to use Kentico API (DLLs) from an external application please follow the steps I described in another answer.
You also asked about the site identifier (siteId or siteName params of the BizFormInfoProvider.GetBizFormInfo() method). They refer to the SiteInfo object in Kentico (DB table CMS_Site). You can find site name if you navigate to Site->Edit site->General->Site code name.
If you don't want to use Kentico DLLs there is another option - using Kentico REST endpoint.

Get Facebook objects information with C#

I'm new to facebook development. I'm using C# on Windows Form and I'm searching for a way to get information about a post on facebook.
I've read documentation and see that I can use FQL to query facebook object.
My questions:
is using FQL it a good way in WindowsForm solutions ?
I need to get the count on how many 'like' are done on an object (link or photo). Can I do this with like Table ?
I need to know who is sharing my facebook objects (link or photo). Where is the relative Table I can use ?
Thanks for your help.
I haven't had a lot of luck with FQL and prefer to use the graph api
Using this in combination with the facebook SDK dll you can quickly retrieve information about a post as a json object using the following code.
var client = new FacebookClient(accessToken);
var jsonPost = (JsonObject) client.Get(postId);
As for seeing who has shared your objects I'm not sure if that can be done using the graphAPI, you would be able to see likes and comments of a object by using
var client = new FacebookClient(accessToken);
var jsonLikes = (JsonObject) client.Get(postId + "/likes");
var jsonComents = (JsonObject) client.Get(postId + "/comments");

Not getting Twitter api statuses

I am trying to use the following twitter API, but am unable to get user statuses. Tell me what is the error?
WebClient connectTwitter = new WebClient();
connectTwitter.DownloadStringCompleted += new
DownloadStringCompletedEventHandler(connectTwitter_DownloadStringCompleted);
connectTwitter.DownloadStringAsync(new
Uri("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=BarackObama"));
You need to authenticate in order to access the Twitter API.
You'll probably want to start here: https://dev.twitter.com/docs/auth/tokens-devtwittercom, and you might want to consider using a C# wrapper for the API, like this: https://github.com/danielcrenna/tweetsharp.

How do I get Google Calendar feed from user's access token?

Using OAuth I do get access token from Google. The sample that comes with Google and even this one:
http://code.google.com/p/google-api-dotnet-client/source/browse/Tasks.SimpleOAuth2/Program.cs?repo=samples
show how to use Tasks API. However, I want to use Calendar API. I want to get access to user's calendar. Can anybody tell me how do I do that?
Take a look at the samples:
Getting Started with the .NET Client Library
On the right side of the page linked above there is a screen shot showing the sample projects contained in the Google Data API solution. They proofed to be very helpful (I used them to start my own Google Calendar application).
I recommend keeping both your own solution and the sample solution open. This way you can switch between the examples and your own implementation.
I also recommend to use the NuGet packages:
Google.GData.AccessControl
Google.GData.Calendar
Google.GData.Client
Google.GData.Extensions
and more ...
This way you easily stay up to date.
Sample to get the users calendars:
public void LoadCalendars()
{
// Prepare service
CalendarService service = new CalendarService("Your app name");
service.setUserCredentials("username", "password");
CalendarQuery query = new CalendarQuery();
query.Uri = new Uri("https://www.google.com/calendar/feeds/default/allcalendars/full");
CalendarFeed calendarFeed = (CalendarFeed)service.Query(query);
Console.WriteLine("Your calendars:\n");
foreach(CalendarEntry entry in calendarFeed.Entries)
{
Console.WriteLine(entry.Title.Text + "\n");
}
}

c# program to call Google+ API and Custom Search API from Google

Can you please tell me via a code sample how I can write a C# program that will call
the Google+ API and Custom Search API of Google.
I know there is a brief description of it on :::::
URL:https://developers.google.com/+/api/
URL:https://developers.google.com/custom-search/v1/using_rest
URL:http://code.google.com/p/google-api-dotnet-client/wiki/OAuth2
But the process mentioned in the links in doing the above as given in the documentation is
not very clear.
Is there a simple illustration through C# code that I can use to call Google+ API and Custom
Search API?
The Google API Dotnet Client project contains .NET wrappers form most of Google's APIs, including Google+.
They do have several examples but not for all of their APIs, yet.
A Google+ example from their page to query for public activities is:
CommandLine.EnableExceptionHandling();
CommandLine.DisplayGoogleSampleHeader("PlusService API");
// Create the service.
var objService= new PlusService();
objService.Key = ""; //put in user key.
var acts = objService.Activities.Search();
acts.Query = "super cool";
acts.MaxResults = 10;
var searchResults = acts.Fetch();
if (searchResults.Items != null)
{
foreach (Activity feed in searchResults.Items)
{
//extract any property of uer interest
CommandLine.WriteResult(feed.Title, feed.Actor);
}
}

Categories