New Facebook App for Windows Phone

clip_image001I have been using the Facebook features of my Windows Phone for a while now but mostly through the People Tile and NOT the Facebook app. Thankfully now there is a new and improved Facebook Application.

Download it and let me know what you think.

The marketplace link   http://www.windowsphone.com/en-US/apps/82a23635-5bd9-df11-a844-00237de2db9e

Their facebook page : http://www.facebook.com/apps/application.php?id=135892916448833

Engadgets post on it  : http://www.engadget.com/2012/02/14/facebook-app-windows-phone-update/

Phone Gap Tutorial #1- Getting Started


This is a   tutorial Series in which I will create a phone gap application for each of the platforms it supports. It is mostly a journey of my own that you get to follow along on.  I will start with Windows Phone and then convert it to IPhone, IPad, Android, Blackberry, Symbian. We will discuss tips and tricks along the way.

In this post, we will look at what you need to do to get started using using Windows Phone.  The first thing you need to do is download the tools.

Go to http://phonegap.com and click on the Download PhoneGap button. It is currently at version 1.41image

The file will be called callback-phonegap-1.4.1-0-g0d1f305.zip (of course the number will change as new updates are applied).  It is called callback-phonegap because…. now take a breath here…. Nitobi, the company that create (at a hackathon… cool), was acquired by  Adobe who then jointly with Nitobi donated the project to the Apache Software Foundation (ASW).  This is a good thing since Adobe will continue to back the project while allowing others to continue to contribute. Now why is it called Callback you ask?  Well, the name inside ASW for is Callback….. or at least it was, it has since been changed to Apache Cordova, so I assume the file name will change soon to.

So once you have downloaded and unziped the file, you will want to navigate to \callback-phonegap-1.4.1-0-g0d1f305\callback-phonegap-0d1f305\lib\windows.  You will see many things in here, but we are only concerned with one right now. PhoneGapStarter.zip (We will talk about PhoneGapCustom.zip later).  We want to copy this to our Visual Studio Templates folder so we can create projects in Visual Studio. 

Copy the PhoneGapStarter.zip file to C:\Users\[USERNAME]\Documents\Visual Studio 2010\Templates\ProjectTemplates\Silverlight for Windows Phone

Now open up Visual Studio (This works with the full or express version) and go to File –> New Project

Select Visual C# –> Silverlight for Windows Phone

You should see a project template for PhoneGapStarter

image

Name Your project and hit OK.  That will create your project.

In the next tutorial, we will walk through all off the files and the set up of your New Phonegap project.

Other Posts in this Series

(This list will automatically grow as I write them)

[catlist name=phone-gap-tutorial]



WP7 Rest … The Easy Way

Over and over again, I see developers that have this great idea for an application that pulls cool data from a  great services BUT get tied up in the implementation of “Getting It Done”.  So I thought I would show you a quick and easy way to get REST data from a service, transfer the JSON data to a POCO list and Bind it to a listbox.  (In under 3 minutes)

On your Mark

Get Set

Go.

The first think you need to do is find some Data that is interesting to you.  For me, I LOVE coffee so I want to create an application that shows me all the coffee places that are near to me.  I can do this using Bing Search  http://msdn.microsoft.com/en-us/library/dd251014.aspx 

Specifically, I am going to use the PhoneBook Request part of the API that is like a Yellow Pages API.  It will give me all the business that designate themselves as “Coffee” places.

(Yes I know I am not using MVVM)

The first thing I do is Create a method called GetData() and call it from my MainPage() Constructor

  public MainPage()
        {
            InitializeComponent();
            GetData();
        }

        private void GetData()
        {
            string uri = "http://api.bing.net/json.aspx?AppId=YOUR_APP_ID&Version=2.0&Market=en-US&Query=Coffee&Sources=phonebook&latitude=33.8563&longitude=-118.1232";
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(uri));
            request.BeginGetResponse(new AsyncCallback(ReadCallback), request);

        }

In GetData() the first thing I do is make a call to the BING  API. 

The first part of the call shows that I want json returned and supplies my App_ID (Removed from post)  ( You can get your own Bing API key here http://msdn.microsoft.com/en-us/library/dd251020.aspx )

http://api.bing.net/json.aspx?AppId=YOUR_APP_ID

Next I set the version, Market, and what I am looking for

&Version=2.0&Market=en-US&Query=Coffee&

And finally, I tell it I am looking at the phonebook part of the API and where I want to search… In this example I am hardcoding the lat/long but you would of course use the Geo Location from the phone, but I wanted to keep this simple.

Sources=phonebook&latitude=33.8563&longitude=-118.1232";

Next, We then need to make the call to the service.  We will use a HttpWebRequest by passing it the URI we just created

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(uri));

And then making in the call and supplying it the CallBack method (Where the call returns to when it is finished)

request.BeginGetResponse(new AsyncCallback(ReadCallback), request);

Now here is the fun part. To work with the JSon data the is returned from this query, we need to create the class structure that represents the data…….. ugggggg what a pain right?   Nope Wrong, All we need to do is use http://json2csharp.com/    Just paste in either the JSon returned OR the URI String, and it will create the classes for you. So when I paste in my URI String above, it gives me the following.

(you can, of course, break up these classes into separate files but for now, I just pasted them at the bottom of the MainPage.xaml.cs file.)

 

public class Query
    {
        public string SearchTerms { get; set; }
    }

    public class Result
    {
        public string Title { get; set; }
        public string Url { get; set; }
        public string Business { get; set; }
        public string PhoneNumber { get; set; }
        public string Address { get; set; }
        public string City { get; set; }
        public string StateOrProvince { get; set; }
        public string CountryOrRegion { get; set; }
        public string PostalCode { get; set; }
        public double Latitude { get; set; }
        public double Longitude { get; set; }
        public string UniqueId { get; set; }
        public string DisplayUrl { get; set; }
    }


    public class Phonebook
    {
        public int Total { get; set; }
        public int Offset { get; set; }
        public string LocalSerpUrl { get; set; }
        public string Title { get; set; }
        public List<Restuarnt> Results { get; set; }
    }

    public class SearchResponse
    {
        public string Version { get; set; }
        public Query Query { get; set; }
        public Phonebook Phonebook { get; set; }
    }

    public class RootObject
    {
        public SearchResponse SearchResponse { get; set; }
    }

Now that you have the classes that hold the json that is returned, all you need to do is create the ReadCallback Method (Defined above)

private void ReadCallback(IAsyncResult asynchronousResult) 
        { 
            HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState; 
            HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult); 
            using (StreamReader streamReader1 = new StreamReader(response.GetResponseStream())) 
            { 
                string resultString = streamReader1.ReadToEnd(); 
                var ser = new DataContractJsonSerializer(typeof(RootObject));

                var stream = new MemoryStream(Encoding.Unicode.GetBytes(resultString));
                DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(RootObject));
                RootObject myBook = (RootObject)jsonSerializer.ReadObject(stream);
              
                

                Deployment.Current.Dispatcher.BeginInvoke(() => coffeeShops.ItemsSource = myBook.SearchResponse.Phonebook.Results); 
                
            } 
        }

You can see that we use a stream reader to read the results and then use a DataContractJsonSerializer to add the data to the RootObject (Root Object is one of the classes that were created for us that encapsulates all the others)

On the last line, I marshall the data to the UI thread using Dispatcher.BeginInvoke and bind it to a ListBox called coffeeShops.

That’s IT….

Now it took me 30 minutes to write this up, but it should take you only 3 minutes to implement.

Enjoy Smile

Free Windows Phone

image

UPDATE:  YES THIS IS AN OLDER POST BUT I STILL HAVE PHONES

Are you looking for a Free Windows Phone?  Are you a developer?  Do you live on the West Coast of the US? (CA, AZ,ID, WA, NM, CO, NV, OR, UT)  Then I have a phone for you. (Read Below)  If you have been looking for a free windows phone to do development on then all you need to do is contact me.  Email me at Daniel.Egan@microsoft.com and I will send you all the details. (INCLUDE WHERE YOU LIVE in the email or I will not respond  — too many emails :)  )

I want to be clear on a couple of things.

  1. I am getting these phones to developers that are writing applications for the marketplace
  2. I have a limited supply (First ones to get me the info I need)
  3. You must live on the West Coast of the US  (CA, AZ,ID, WA, NM, CO, NV, OR, UT)

If you do not live on the West Coast of the US, I can try to find your windows phone champ for you.  Just post the request here :  http://thesociablegeek.com/forum/?mingleforumaction=viewforum&f=3.0

This does not mean that they will have a phone for you, but if you are developing for Windows Phone, you WANT to know your windows phone champ.  If they don’t have phones, they may know someone who does ( I repeat, I am not saying they have phones Smile , but they may know a way.  Either way, they are a great resource for you. )

So all of you West Coasters, get your Free Windows Phone while they last.  Email me at Daniel.Egan@microsoft.com for the details. UPDATE :  PLEASE INCLUDE WHERE YOU ARE FROM SO I DONT HAVE TO ASK YOU IN EMAIL. (Slowes down the process)

Windows Phone 7.5 Training Kit

Windows PhoneThe new Windows Phone 7.5 Training Kit have been released.  This time there is a Basic Version and an Advanced Version of the Windows Phone 7.5 Training Kit

You can download both of them here : http://bit.ly/w2xF6s

 

The Basic Labs Include

  • Hello Windows Phone
  • Building your first Windows Phone 7 Application
  • Windows Phone Navigation and Controls
  • Application Lifecycle
  • Using the Pivot and Panorama Controls
  • Accessing Windows Phone 7 Devices
  • Game Development with XNA Framework
  • Discovering Windows Phone 7 Device Capabilities
  • PhotoFun
  • Launchers
  • Choosers
  • Weather Service Push Notifications
  • Using Bing Maps

The Advanced Labs Include

  • Catapult Wars Lab
  • Multi-Touch Game Development with XNA
  • 3D Game Development with XNA Framework
  • Using a local database in the “Tidy” application
  • Background Transfer Service in the “Tidy” application
  • Fast Application Switching in the “Tidy” application
  • Creating Notifications in the “Tidy” application
  • Adding Multitasking to your application
  • XNA 3D Model Viewer
  • Search Integration
  • Background Audio Agents

You can download both of them here : http://bit.ly/w2xF6s

Live Tiles–Windows Phone Workshop

Today is the day we start the Windows Phone Workshop.  You can either watch it here (below) or head over to livestream. You can find the recorded session below..

Here are the files :

http://dl.dropbox.com/u/32614089/SimpleTileDemo.zip

http://dl.dropbox.com/u/32614089/SimpleTileDemo%20WithPush.zip

SPECIAL NOTE : Since we were doing alot of testing, you will want to skip to 1 hour in to see the session.

Watch live streaming video from microsoftdevelopers at livestream.com

Suggest a Windows Phone Workshop

unclesamNow that we are doing Windows Phone Workshops, we would like to know what YOU would like to see.  There are so many things to do on Windows Phone that we want to make sure that you get the sessions that are important to you.

All you need to do is either VOTE for a suggestion already there OR add your own suggestion.  Let me know if you have any suggestions.

Vote Here  http://thesociablegeek.com/workshop-suggestions/

WindowsPhoneWorkshops

Video Chat for WP7–TANGO

They have been talking about it for a while and it has finally hit the market place.  Tango, the Video Chat application for WP7.  It will obviously work better with the new phones with front facing cameras… but it also works on my Samsung Focus… Check out the video below.

 

 

 

 

It of course works best over wifi, but will also work over 4G and 3G

 

image

 

Learn more at http://www.tango.me/ Like us on Facebook at http://www.facebook.com/TangoMe Follow us on Twitter at http://www.twitter.com/tangome Watch us on YouTube at http://www.youtube.com/TangoMe Need Help? Visit http://support.tango.me

This work is licensed under a Creative Commons license.