日期:2011-07-29 浏览次数:20527 次
Imports System.IO
Imports System.Net
Imports System.Web
Public Delegate Sub BaiduAlbumEventHandler(ByVal msg As String) '事件委托
Public Class baiduAlbum
''' 声明事件
Public Event UpPicsComplete As BaiduAlbumEventHandler
Public Event UpPicsProcess As BaiduAlbumEventHandler
Public Event DownPicsComplete As baiduAlbumEventHandler
Public Event DownPicProcess As BaiduAlbumEventHandler
Public Event DeletePicsComplete As BaiduAlbumEventHandler
Public Event DeletePicProcess As BaiduAlbumEventHandler
'定义数据成员
'''用户
Dim _username As String
Dim _password As String
Dim _userDomain As String
Dim _userHeadPic As String
'''全部
Dim _albumUsedSpace As Double
Dim _albumCount As Integer
Dim _pictureCount As Integer
'''相册
Dim _albumID As ArrayList
Dim _albumName As ArrayList
Dim _albumDesc As ArrayList
Dim _albumPower As ArrayList
Dim _albumURL As ArrayList
Dim _albumPicCount As ArrayList
'''图片
Dim _pictureID() As ArrayList
Dim _pictureDesc() As ArrayList
Dim _pictureURL() As ArrayList
Dim _pictureSize() As ArrayList
Dim Encode As System.Text.Encoding = System.Text.Encoding.GetEncoding("GB2312") '编码方式
Dim commandURL As String '操作命令地址
Dim Http As HttpProc '实现http协议的类
Dim r As System.Text.RegularExpressions.Regex '正则表达式
Dim m As System.Text.RegularExpressions.Match
''' 登录
Function Login(ByVal username As String, ByVal password As String) As Boolean
_username = username
Dim postData, LoginURL As String
LoginURL = "http://passport.baidu.com/?login" '登陆地址
postData = "username=" + HttpUtility.UrlEncode(username, Encode) + "&password=" + HttpUtility.UrlEncode(password, Encode) '请求数据
Http = New HttpProc(LoginURL, postData)
Dim RespHtml As String
RespHtml = Http.Proc(True)
If Http.strErr <> "" Then
MsgBox(Http.strErr)
Http.strErr = ""
ElseIf Len(RespHtml) < 200 Then
_userDomain = GetDomain(_username) '获取用户域名
If _userDomain <> "" Then
Http.cookiePost = Http.cookieGet
commandURL = "http://hiup.baidu.com/" + _userDomain + "/commit"
Return True
End If
ElseIf InStr(RespHtml, "不