This is an ASP.net c# wrapper class designed for you to integrate your website easily with Web Wizs forum easily.
The only issue at the moment is with the cookies, they seem to work intermitetly when calling the login function. I think it has something to do with paths, if anyone can work this out for me it would be great :)
Usage
Makes integration with membership easy. Use like follows:
// Create a new user and print out some of their details ForumAPI.WebWizUserDetails me = ForumAPI.NewUser("NewUser", "Password", true); Response.Write(me.Username); Response.Write(me.Posts); Response.Write(me.JoinDate);
// Load user by username. Also can do it by ID or XML data ForumAPI.WebWizUserDetails SomeUser = new ForumAPI.WebWizUserDetails("NewUser");
// Suspend them SomeUser.Suspend();
// Unsuspend SomeUser.Unsuspend();
// Load their cookie data SomeUser.GetCookieData();
// Login with this cookie data which expires in 10 mins SomeUser.CookieData.LoadCookie((double)10);
// Login with this cookie data which expires in 10 days SomeUser.CookieData.LoadCookie((int)10);
|
There's a lot more functions in there, browse the code to see. It's commented for intellisense to make it easy to use.
Notes
This isn't thoroughly tested, there isn't much error checking going on, so use at your own risk. It's a work in progress for my website, if I ever update it significantly I'll try and post it in here.
Installation
You need to add the following keys to your <appSettings> in your web.config:
<add key="AdminUsername" value="Administrator"/> <add key="AdminPassword" value="letmein"/> <add key="ForumAPILocation" value="http://localhost/ScirraNew/forum/HttpAPI.asp"/>
|
Then create a new class in your App_Code folder called ForumAPI.cs.
[code]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.IO;
using System.Configuration;
using System.Xml;
/// <summary>
/// ASP.net Wrapper for the WebWizAPI V1.0
/// (c) Thomas Gullen, 2011
/// http://www.Scirra.com
///
/// Free to use as long as this
/// copyright information remains unedited.
/// Distribution prohibited without authorisation
/// from Scirra.com
/// </summary>
///
/// TODO:
/// CreateMember
public class ForumAPI
{
/// <summary>
/// The date format parameter for web wi
/// </summary>
public static class WebWizDateFormat
{
public const string USFormat = "mm/dd/yy";
public const string UKFormat = "dd/mm/yy";
public const string YYDDMMFormat = "yy/dd/mm";
public const string YYMMDDFormat = "yy/mm/dd";
}
/// <summary>
/// Cookie information for a user
/// </summary>
public class WebWizCookie
{
public string Username { get; set; }
public int UserID { get; set; }
public string CookieName { get; set; }
public string CookieKey { get; set; }
public string CookieData { get; set; }
public string CookiePath { get; set; }
public string ForumPath { get; set; }
/// <summary>
/// Loads cookie data
/// </summary>
/// <param name="Username">Username to load cookie data for</param>
public WebWizCookie(string Username)
{
GetCookieByUsername(Username);
}
/// <summary>
/// Turns cookie data into actual ASP.net cookie
/// </summary>
/// <param name="MinutesExpiry">Minutes in the future this cookie will expire</param>
public void LoadCookie(double MinutesExpiry)
{
CookieDataToCookie(DateTime.Now.AddMinutes(MinutesExpiry));
}
/// <summary>
/// Turns cookie data into actual ASP.net cookie
/// </summary>
/// <param name="MinutesExpiry">Minutes in the future this cookie will expire</param>
public void LoadCookie(int DaysExpiry)
{
CookieDataToCookie(DateTime.Now.AddDays(DaysExpiry));
}
/// <summary>
/// Turns cookie data into actual ASP.net cookie
/// </summary>
/// <param name="MinutesExpiry">Datetime this cookie will expire</param>
public void LoadCookie(DateTime ExpiryDate)
{
CookieDataToCookie(ExpiryDate);
}
private void CookieDataToCookie(DateTime Expiry)
{
HttpContext.Curr