creating an event app for facebook
Just finished a Facebook app (CSS498 Win Phone Client) with Jonathan Lynn for the Windows Phone 7.1 in Silverlight and the Codeplex Facebook SDK. The app requirements were to generate wall posts and event posts. Our project ended up having an event creation page and to add friends to the event (as you type the name in, it gives you a suggestion to auto complete the form).
So there were a few issues that I ran in to:
- setting the date using the Windows Phone interface
- use Facebook as a developer
- getting access to the Facebook app from my user account
facebook developer login
So first things first, I logged into Facebook as a developer and got an appID and appSecret. In the codeplex website, the facebook C# SDK does not allow users to gain permissions on the account to use the app. It’s tricky, I needed to use a Windows Form with my appID with the permissions to allow my app to my account.
the OAuth issue
The issue for WP7 is the Facebook Codeplex SDK eats it at
if (FacebookOAuthResult.TryParse(e.Uri, out oauthResult))
which means it can’t get OAuth. It means it can’t allow the user to use the app because the user hasn’t allowed it. What should happen is the phone should get you to the following screen:
The issue has been documented as a bug on the Facebook developer’s website. On that subject, here’s a cool Facebook link to see the status of the Facebook API Platform (while we were working on our app, the test user stopped working on October 21st, 2011).
setting DateTime
Time picker was an interesting problem. I found a demo of a WP7 date and time picker but I also found that there was an issue with the Microsoft.Phone.Controls.Toolkit from Silverlight Codeplex. The datepicker and timepicker were visually available; however, the callback on:
this.datePicker.ValueChanged += new EventHandler(picker_ValueChanged);
void picker_ValueChanged(object sender, DateTimeValueChangedEventArgs e)
{
DateTime date = (DateTime)e.NewDateTime;
this.textBlock.Text = date.ToString("d");
}
So the event is only called when the month and date are changed. The date does not get the time or is related to the event click. So instead of using that, I did some quick research on how to set a DateTime. What I ended up at was a MSDN site for DateTime Parse Method. The method below was my quick and dirty solution to get both the date and time from datepicker and timepicker and setting that to a DateTime object.
private void SetDate()
{
string dateandtime;
string selectDate = "";
bool space;
dateandtime = date.Date.ToString();
space = false;
// get the first half of the string
// (the date in the format: month-date-year)
for (int i = 0; i < dateandtime.Length; ++i) {
if (dateandtime[i].Equals(' '))
break;
else if (!space)
selectDate += dateandtime[i];
}
dateandtime = timePicker.Value.ToString();
selectDate += " ";
space = false;
// get the second half of the string
// (time in the format hour:minutes)
for (int i = 0; i < dateandtime.Length; ++i) {
if (dateandtime[i].Equals(' '))
space = true;
else if (space)
selectDate += dateandtime[i];
}
date = DateTime.Parse(selectDate); // date is a DateTime object
}
}
Anyway, here are a couple of images of our app (errr… after the break. I need to do some networking homework).
Tags: C Sharp, CSS497, Facebook API, Silverlight, WP7


