Archive for the ‘Applications’ Category

How to create a simple Facebook desktop application with C#

Hey there, while surfing the web I found that there are not too much tutorials about how to create a desktop application for facebook.

Here I will show you a really basic tutorial to create a facebook application for your desktop that will update your status.

I’m assuming that you already know the basics about facebook Web Services, if you don’t, go to http://developers.facebook.com/get_started.php

Requirements:

Visual Studio 2008 Express

Facebook Developer Toolkit

1. Add Facebook Components to Visual Studio

Once you have installed the Visual Studio 2008, add the facebook components to the Visual Studio Toolbox.

Right click on the toolbox area and select “Choose Items…”

toolbox

Now click on the “Browse…”  Button, locate the folder where the facebook components are and add the following libraries:

facebook.dll

facebook.desktop.dll

facebook.web.dll <— Add this if you want to create Web Projects

items

Then simply click the “OK” button and you are done.

You can add these components to a new tab named “Facebook” or something if you don’t want to have them on the “General” tab.

2. Create a new project for the application.

Go to File > New Project > Windows Forms Application.

newproject

Drag the “FacebookService” component to your application Form and add the API Key and the Secret Key that facebook has already assign to your application.

fbservice

Now add a Button to Log In, a TextBox to Write your status and another Button to Share your status.

appform

Double Click on the “Login” Button to write the code that it will execute. Add the following lines:

facebookService1.ConnectToFacebook();

try
{
facebookService1.GetExtendedPermission(facebook.Types.Enums.  Extended_Permissions.status_update);
}
catch (Exception exception)
{
MessageBox.Show(this, exception.Message, “Error”);
}

The previous lines will connect you to facebook and ask for the necessary permissions that the application needs to run.

Now lets tell the “Share” Button to do something. Double click on it and add the following lines to the code:

String status = updateText.Text;
Boolean updated = facebookService1.API.users.setStatus(status);
if (updated)
{
updateText.Text = “”;
}

These previous lines will update your status on facebook and will clear the textbox.

Now you can run your application and update your status from the desktop.

I hope that this tutorial help. Feel free to write questions or comments if you have them.

WebLab | Salvador Fuentes

Advertisements

How can I merge C# with popular social Web Services?

Nowadays we can create distributed systems using Web Services. A Web Service is an applicative logic unit that we can access using internet standard protocols. With these services we can create applications that are able to connect with servers in the web and allowing us to obtain information from them.

C# uses SOAP (Simple Object Access Protocol) as a communication protocol for interacting with different servers through Web Services.

Social Networks like Twitter or Facebook offer Web Services with methods that allow us interact with the information we got from them, these methods are included in the Application Programming interface (API) of each Social Network. To be able to communicate with these API’s we need to download and install the necessary libraries, this way C# will communicate transparently with these Web Services.

WebLab | Salvador Fuentes

How can I get the most functionality of a book-shaped interface?

I think that there are a lot of good ideas to create an excellent and functionality application, like our project a Twitter Desktop Application. There are some easy API’s to develop whatever you want but one of the main objectives is the Graphics User Interface. First we need to have cleared some aspects before the main theme, the book-shaped interface.

The first thing I need to get clear as a developer is the Form orientation, vertical or horizontal. The most common for example, a Twitter App orientation is in a vertical way because of the stack and the appearance of the twits like a mini blog (inverse chronically order). I think that a horizontal Twitter App would be interesting and something out of the common.

The next thing we should care about is the size of the form. Many people including myself prefer a form with small sizes, like the half or the fourth part of our screen because I like to see my desktop full of windows forms, like a real desktop where I can drop everything wherever I want having multiple open windows.

A personalized application is the new black. We are always looking around modifying our interface, with colors, backgrounds, pictures and more. The objective here is to “create” an application with your sign.

The next thing is to have an intuitive menu, something clear and easy to use. Think that everyone would like to use your application.

Finally create a book-shaped application and your content display. We want to make that our application looks like a book and create something new. In a book we can see the first page (page one on your left side) and the next page (page two on the right side). When we pass from page one to page two, now our current page is number two, the previous is the page one and the next page (page 3) we can’t see it. So a solution is to have a current page that is the main page in the center and the previous page on the left. When we want to see a previous page in the current, we need to divide the application in 3 parts, the middle part would be your current page (a previous one), the part on the left would be another previous page from the current and the third part (on the right of the current) would be the next page. This create the effect that you just turn the page and now you can see instead of two, three pages at the same time.

Tweeter in a BookNever stop thinking, never stop innovating

flavioeverardo|WebLab

How to use .NET dataGridView component to display twitter timeline using C#

Hey, this would be a basic tutorial about how to use the daytaGridView component to display your friends timeline.

Requirements:

-Visual Studio Express 2008

-Twitterizer Framework

1. Add the twitterizer library to the project

Menu>Project>Add Reference…

01tutorial

Select the current path of the Twitterizer libray that you donwloaded

02tutorial

2. Add the Twitterizer libray to the project

using Twitterizer.Framework;


3. Add the dataGridView component to the interface

Toolbox>data>dataGridView

13tutorial

4. Also add a button with the text “Update timeline”

14tutorial

5. Create a method called updateTimeline with no parameters like this:

private void updateTimeline()
{
Twitter t =new Twitter(“user”, “password”);
try
{
dataGridView1.DataSource = t.Status.FriendsTimeline(Parameters);
}
catch (TwitterizerException ex)
{
MessageBox.Show(this, ex.Message, “Error”);
}
}

private void updateTimeline()

{

Twitter t =new Twitter(“user”, “password”);
try
{
dataGridView1.DataSource = t.Status.FriendsTimeline(Parameters);
}
catch (TwitterizerException ex)
{
MessageBox.Show(this, ex.Message, “Error”);
}
}

6. Double click through the button and call the method that we had created before.

private void buttonSignIn_Click(object sender, EventArgs e)

{

updateTimeline();

}

7. Run your application to see your Friends Timeline status.

03tutorial

As you can see, theres too much information in the dataGridView, so we need to chage some properties in order to improve the appearence of the timeline.
8. In the design view, look for a play button in the dataGridView component and click on it
04tutorial
Then clic on Edit Columns

First colum is for the user06tutorial

the second one is for the status
07tutorial
9. Then bind the colums with some property like this
The column Status will show the data from the Text column

08Tutorial
The column User will show the data from the TwitterUser column
09Tutorial
10. Add this line of code to the method UpdateTimeline

private void updateTimeline()

{
Twitter t = new Twitter(“user”, “password”); //use your own username and password
try
{
dataGridView1.AutoGenerateColumns = false;
dataGridView1.DataSource = t.Status.FriendsTimeline();
}
catch (TwitterizerException ex)
{
MessageBox.Show(this, ex.Message, “Error”);
}
}
//with this the dataGridView won’t add more columns
11. Run your application and watch the new interface
11tutorial

12. Finally your code should be like this
12tutorial

Ok this is a basic tutorial of how to use the dataGridView component to display the twitter timeline, but of course, the dataGridView compont has a lot of methods and properties to change the behavior of this component.
I hope this tutorial will be helpfull for this persons who are starting with twitter application using the twitterizer framework.
WebLab|Osvaldo Huerta

To be or not to be …

Seriously, how could anyone live with him/herself if he/she does not knows the answers to the following fundamental life questions:

  • Is there any room left for Yet Another Twitter Applicattion (YATA) ?
  • Have to work remotely? I present you my friends Yuuguu + dropbox + Skype.
  • How can I get the most functionality of a book-shaped interface?
  • How can I merge C# with popular social Web Services? ( dammit, this question still wakes me up at night with terror)
  • Hey, I want to pod (shorten) my urls using C#, can I ?

Well mate, fret not, all of these questions will be answered here, shortly, and we assure you, you will be able to sleep easy again 🙂

WebLab|Strazzulla