1
using System;
2
using System.Collections.Generic;
3
using System.IO;
4
using System.Text;
5
using System.Web;
6
using System.Web.Security;
7
using System.Xml;
8
using LiveBlog.Core;
9
10
namespace LiveBlog.Core.API.MetaWeblog
11
...{
12
/**//// <summary>
13
/// HTTP Handler for MetaWeblog API
14
/// </summary>
15
internal class MetaWeblogHandler : IHttpHandler
16
...{
17
IHttpHandler Members#region IHttpHandler Members
18
19
/**//// <summary>
20
/// Gets a value indicating whether another request can use the <see cref="T:System.Web.IHttpHandler"></see> instance.
21
/// </summary>
22
/// <value></value>
23
/// <returns>true if the <see cref="T:System.Web.IHttpHandler"></see> instance is reusable; otherwise, false.</returns>
24
public bool IsReusable
25
...{
26
get ...{ return false; }
27
}
28
29
/**//// <summary>
30
/// Process the HTTP Request. Create XMLRPC request, find method call, process it and create response object and sent it back.
31
/// This is the heart of the MetaWeblog API
32
/// </summary>
33
/// <param name="context"></param>
34
public void ProcessRequest(HttpContext context)
35
...{
36
try
37
...{
38
string rootUrl = Utils.AbsoluteWebRoot.ToString();// context.Request.Url.ToString().Substring(0, context.Request.Url.ToString().IndexOf("metaweblog.axd"));
39
XMLRPCRequest input = new XMLRPCRequest(context);
40
XMLRPCResponse output = new XMLRPCResponse(input.MethodName);
41
42
switch (input.MethodName)
43
...{
44
case "metaWeblog.newPost":
45
output.PostID = NewPost(input.BlogID, input.UserName, input.Password, input.Post, input.Publish);
46
break;
47
case "metaWeblog.editPost":
48
output.Completed = EditPost(input.PostID, input.UserName, input.Password, input.Post, input.Publish);
49
break;
50
case "metaWeblog.getPost":
51
output.Post = GetPost(input.PostID, input.UserName, input.Password);
52
break;
53
case "metaWeblog.newMediaObject":
54
output.MediaInfo = NewMediaObject(input.BlogID, input.UserName, input.Password, input.MediaObject, context);
55
break;
56
case "metaWeblog.getCategories":
57
output.Categories = GetCategories(input.BlogID, input.UserName, input.Password, rootUrl);
58
break;
59
case "metaWeblog.getRecentPosts":
60
output.Posts = GetRecentPosts(input.BlogID, input.UserName, input.Password, input.NumberOfPosts);
61
break;
62
case "blogger.getUsersBlogs":
63
case "metaWeblog.getUsersBlogs":
64
output.Blogs = GetUserBlogs(input.AppKey, input.UserName, input.Password, rootUrl);
65
break;
66
case "blogger.deletePost":
67
output.Completed = DeletePost(input.AppKey, input.PostID, input.UserName, input.Password, input.Publish);
68
break;
69
case "blogger.getUserInfo":
70
//Not implemented. Not planned.
71
throw new MetaWeblogException("10", "The method GetUserInfo is not implemented.");
72
break;
73
case "wp.newPage":
74
output.PageID = NewPage(input.BlogID, input.UserName, input.Password, input.Page, input.Publish);
75
break;
76
case "wp.getPageList":
77
case "wp.getPages":
78
output.Pages = GetPages(input.BlogID, input.UserName, input.Password);
79
break;
80
case "wp.getPage":
81
output.Page = GetPage(input.BlogID, input.PageID, input.UserName, input.Password);
82
break;
83
case "wp.editPage":
84
output.Completed = EditPage(input.BlogID, input.PageID, input.UserName, input.Password, input.Page, input.Publish);
85
break;
86
case "wp.deletePage":
87
output.Completed = DeletePage(input.BlogID, input.PageID, input.UserName, input.Password);
88
break;
89
}
90
91
output.Response(context);
92
}
93
catch (MetaWeblogException mex)
94
...{
95
XMLRPCResponse output = new XMLRPCResponse("fault");
96
MWAFault fault = new MWAFault();
97
fault.faultCode = mex.Code;
98
fault.faultString = mex.Message;
99
output.Fault = fault;
100
output.Response(context);
101
}
102
catch (Exception ex)
103
...{
104
XMLRPCResponse output = new XMLRPCResponse("fault");
105
MWAFault fault = new MWAFault();
106
fault.faultCode = "0";
107
fault.faultString = ex.Message;
108
output.Fault = fault;
109
output.Response(context);
110
}
111
}
112
113
#endregion
114
115
API Methods#region API Methods
116
117
/**//// <summary>
118
/// metaWeblog.newPost
119
/// </summary>
120
/// <param name="blogID">always 1000 in BlogEngine since it is a singlar blog instance</param>
121
/// <param name="userName">login username</param>
122
/// <param name="password">login password</param>
123
/// <param name="sentPost">struct with post details</param>
124
/// <param name="publish">mark as published?</param>
125
/// <returns>postID as string</returns>
126
internal string NewPost(string blogID, string userName, string password, MWAPost sentPost, bool publish)
127
...{
128
ValidateRequest(userName, password);
129
130
Post post = new Post();
131
132
post.Author = userName;
133
post.Title = sentPost.title;
134
post.Content = sentPost.description;
135
post.IsPublished = publish;
136
post.Slug = sentPost.slug;
137
post.Description = sentPost.excerpt;
138
139
if (sentPost.commentPolicy != "")
140
...{
141
if (sentPost.commentPolicy == "1")
142
post.IsCommentsEnabled = true;
143
else
144
post.IsCommentsEnabled = false;
145
}
146
147
post.Categories.Clear();
148
foreach (string item in sentPost.categories)
149
...{
150
Category cat;
151
if (LookupCategoryGuidByName(item, out cat))
152
post.Categories.Add(cat);
153
else
154
...{
155
// Allowing new categories to be added. (This breaks spec, but is supported via WLW)
156
Category newcat = new Category(item, "");
157
newcat.Save();
158
post.Categories.Add(newcat);
159
}
160
}
161
post.Tags.Clear();
162
foreach (string item in sentPost.tags)
163
...{
164
post.Tags.Add(item);
165
}
166
167
if (sentPost.postDate != new DateTime())
168
post.DateCreated = sentPost.postDate.AddHours(BlogSettings.Instance.Timezone * -1);
169
170
post.Save();
171
172
return post.Id.ToString();
173
}
174
175
/**//// <summary>
176
/// metaWeblog.editPost
177
/// </summary>
178
/// <param name="postID">post guid in string format</param>
179
/// <param name="userName">login username</param>
180
/// <param name="password">login password</param>
181
/// <param name="sentPost">struct with post details</param>
182
/// <param name="publish">mark as published?</param>
183
/// <returns>1 if successful</returns>
184
internal bool EditPost(string postID, string userName, string password, MWAPost sentPost, bool publish)
185
...{
186
ValidateRequest(userName, password);
187
188
Post post = Post.GetPost(new Guid(postID));
189
190
post.Author = userName;
191
post.Title = sentPost.title;
192
post.Content = sentPost.description;
193
post.IsPublished = publish;
194
post.Slug = sentPost.slug;
195
post.Description = sentPost.excerpt;
196
197
if (sentPost.commentPolicy != "")
198
...{
199
if (sentPost.commentPolicy == "1")
200
post.IsCommentsEnabled = true;
201
else
202
post.IsCommentsEnabled = false;
203
}
204
post.Categories.Clear();
205
foreach (string item in sentPost.categories)
206
...{
207
Category cat;
208
if (LookupCategoryGuidByName(item, out cat))
209
post.Categories.Add(cat);
210
else
211
...{
212
// Allowing new categories to be added. (This breaks spec, but is supported via WLW)
213
Category newcat = new Category(item, "");
214
newcat.Save();
215
post.Categories.Add(newcat);
216
}
217
}
218
post.Tags.Clear();
219
foreach (string item in sentPost.tags)
220
...{
221
if (item != null && item.Trim() != string.Empty)
222
post.Tags.Add(item);
223
}
224
225
if (sentPost.postDate != new DateTime())
226
post.DateCreated = sentPost.postDate.AddHours(BlogSettings.Instance.Timezone * -1);
227
228
post.Save();
229
230
return true;
231
}
232
233
/**//// <summary>
234
/// metaWeblog.getPost
235
/// </summary>
236
/// <param name="postID">post guid in string format</param>
237
/// <param name="userName">login username</param>
238
/// <param name="password">login password</param>
239
/// <returns>struct with post details</returns>
240
internal MWAPost GetPost(string postID, string userName, string password)
241
...{
242
ValidateRequest(userName, password);
243
244
MWAPost sendPost = new MWAPost();
245
Post post = Post.GetPost(new Guid(postID));
246
247
sendPost.postID = post.Id.ToString();
248
sendPost.postDate = post.DateCreated;
249
sendPost.title = post.Title;
250
sendPost.description = post.Content;
251
sendPost.link = post.AbsoluteLink.AbsoluteUri;
252
sendPost.slug = post.Slug;
253
sendPost.excerpt = post.Description;
254
if (post.IsCommentsEnabled)
255
sendPost.commentPolicy = "";
256
else
257
sendPost.commentPolicy = "0";
258
259
260
sendPost.publish = post.IsPublished;
261
262
List<string> cats = new List<string>();
263
for (int i = 0; i < post.Categories.Count; i++)
264
...{
265
cats.Add(Category.GetCategory(post.Categories[i].Id).ToString());
266
}
267
sendPost.categories = cats;
268
269
List<string> tags = new List<string>();
270
for (int i = 0; i < post.Tags.Count; i++)
271
...{
272
tags.Add(post.Tags[i]);
273
}
274
sendPost.tags = tags;
275
276
return sendPost;
277
}
278
279
/**//// <summary>
280
/// metaWeblog.newMediaObject
281
/// </summary>
282
/// <param name="blogID">always 1000 in BlogEngine since it is a singlar blog instance</param>
283
/// <param name="userName">login username</param>
284
/// <param name="password">login password</param>
285
/// <param name="mediaObject">struct with media details</param>
286
/// <param name="request">The HTTP request.</param>
287
/// <returns>struct with url to media</returns>
288
internal MWAMediaInfo NewMediaObject(string blogID, string userName, string password, MWAMediaObject mediaObject, HttpContext request)
289
...{
290
ValidateRequest(userName, password);
291
292
MWAMediaInfo mediaInfo = new MWAMediaInfo();
293
294
string path = DateTime.Now.ToString("yyyyMM") + "/";
295
string rootPath = BlogSettings.Instance.StorageLocation + "files/" + path;
296
string serverPath = request.Server.MapPath(rootPath);
297
string saveFolder = serverPath;
298
string fileName = mediaObject.name;
299
300
// Check/Create Folders & Fix fileName
301
if (mediaObject.name.LastIndexOf('/') > -1)
302
...{
303
saveFolder += mediaObject.name.Substring(0, mediaObject.name.LastIndexOf('/'));
304
saveFolder = saveFolder.Replace('/', Path.DirectorySeparatorChar);
305
fileName = mediaObject.name.Substring(mediaObject.name.LastIndexOf('/') + 1);
306
}
307
else
308
...{
309
if (saveFolder.EndsWith(Path.DirectorySeparatorChar.ToString()))
310
saveFolder = saveFolder.Substring(0, saveFolder.Length - 1);
311
}
312
if (!Directory.Exists(saveFolder))
313
Directory.CreateDirectory(saveFolder);
314
saveFolder += Path.DirectorySeparatorChar;
315
316
// Save File
317
FileStream fs = new FileStream(saveFolder + fileName, FileMode.Create);
318
BinaryWriter bw = new BinaryWriter(fs);
319
bw.Write(mediaObject.bits);
320
bw.Close();
321
322
// Set Url
323
string rootUrl = Utils.AbsoluteWebRoot.ToString();// request.Request.Url.ToString().Substring(0, request.Request.Url.ToString().IndexOf("metaweblog.axd"));
324
325
string mediaType = mediaObject.type;
326
if (mediaType.IndexOf('/') > -1)
327
mediaType = mediaType.Substring(0, mediaType.IndexOf('/'));
328
switch (mediaType)
329
...{
330
case "image":
331
case "notsent": // If there wasn't a type, let's pretend it is an image. (Thanks Zoundry. This is for you.)
332
rootUrl += "image.axd?picture=";
333
break;
334
default:
335
rootUrl += "file.axd?file=";
336
break;
337
}
338
339
mediaInfo.url = rootUrl + path + mediaObject.name;
340
return mediaInfo;
341
}
342
343
/**//// <summary>
344
/// metaWeblog.getCategories
345
/// </summary>
346
/// <param name="blogID">always 1000 in BlogEngine since it is a singlar blog instance</param>
347
/// <param name="userName">login username</param>
348
/// <param name="password">login password</param>
349
/// <param name="rootUrl">The root URL.</param>
350
/// <returns>array of category structs</returns>
351
internal List<MWACategory> GetCategories(string blogID, string userName, string password, string rootUrl)
352
...{
353
List<MWACategory> categories = new List<MWACategory>();
354
355
ValidateRequest(userName, password);
356
357
foreach (Category cat in Category.Categories)
358
...{
359
MWACategory temp = new MWACategory();
360
temp.title = cat.Title;
361
temp.description = cat.Title; //cat.Description;
362
temp.htmlUrl = rootUrl + "category/" + cat.Title + BlogSettings.Instance.FileExtension;
363
temp.rssUrl = rootUrl + "feed/category/" + cat.Id.ToString() + BlogSettings.Instance.FileExtension;
364
categories.Add(temp);
365
}
366
367
return categories;
368
}
369
370
/**//// <summary>
371
/// metaWeblog.getRecentPosts
372
/// </summary>
373
/// <param name="blogID">always 1000 in BlogEngine since it is a singlar blog instance</param>
374
/// <param name="userName">login username</param>
375
/// <param name="password">login password</param>
376
/// <param name="numberOfPosts">number of posts to return</param>
377
/// <returns>array of post structs</returns>
378
internal List<MWAPost> GetRecentPosts(string blogID, string userName, string password, int numberOfPosts)
379
...{
380
ValidateRequest(userName, password);
381
382
List<MWAPost> sendPosts = new List<MWAPost>();
383
List<Post> posts = Post.Posts;
384
385
// Set End Point
386
int stop = numberOfPosts;
387
if (stop > posts.Count)
388
stop = posts.Count;
389
390
foreach (Post post in posts.GetRange(0, stop))
391
...{
392
MWAPost tempPost = new MWAPost();
393
List<string> tempCats = new List<string>();
394
List<string> tempTags = new List<string>();
395
396
tempPost.postID = post.Id.ToString();
397
tempPost.postDate = post.DateCreated;
398
tempPost.title = post.Title;
399
tempPost.description = post.Content;
400
tempPost.link = post.AbsoluteLink.AbsoluteUri;
401
tempPost.slug = post.Slug;
402
tempPost.excerpt = post.Description;
403
if (post.IsCommentsEnabled)
404
tempPost.commentPolicy = "";
405
else
406
tempPost.commentPolicy = "0";
407
tempPost.publish = post.IsPublished;
408
for (int i = 0; i < post.Categories.Count; i++)
409
...{
410
tempCats.Add(Category.GetCategory(post.Categories[i].Id).ToString());
411
}
412
tempPost.categories = tempCats;
413
414
for (int i = 0; i < post.Tags.Count; i++)
415
...{
416
tempTags.Add(post.Tags[i]);
417
}
418
tempPost.tags = tempTags;
419
420
sendPosts.Add(tempPost);
421
422
}
423
424
return sendPosts;
425
}
426
427
/**//// <summary>
428
/// blogger.getUsersBlogs
429
/// </summary>
430
/// <param name="appKey">Key from application. Outdated methodology that has no use here.</param>
431
/// <param name="userName">login username</param>
432
/// <param name="password">login password</param>
433
/// <returns>array of blog structs</returns>
434
internal List<MWABlogInfo> GetUserBlogs(string appKey, string userName, string password, string rootUrl)
435
...{
436
List<MWABlogInfo> blogs = new List<MWABlogInfo>();
437
438
ValidateRequest(userName, password);
439
440
MWABlogInfo temp = new MWABlogInfo();
441
temp.url = rootUrl;
442
temp.blogID = "1000";
443
temp.blogName = BlogSettings.Instance.Name;
444
blogs.Add(temp);
445
446
return blogs;
447
}
448
449
/**//// <summary>
450
/// blogger.deletePost
451
/// </summary>
452
/// <param name="appKey">Key from application. Outdated methodology that has no use here.</param>
453
/// <param name="postID">post guid in string format</param>
454
/// <param name="userName">login username</param>
455
/// <param name="password">login password</param>
456
/// <param name="publish">mark as published?</param>
457
/// <returns></returns>
458
internal bool DeletePost(string appKey, string postID, string userName, string password, bool publish)
459
...{
460
ValidateRequest(userName, password);
461
try
462
...{
463
Post post = Post.GetPost(new Guid(postID));
464
post.Delete();
465
post.Save();
466
}
467
catch (Exception ex)
468
...{
469
throw new MetaWeblogException("12", "DeletePost failed. Error: " + ex.Message);
470
}
471
472
return true;
473
}
474
475
/**//// <summary>
476
/// wp.newPage
477
/// </summary>
478
/// <param name="blogID">blogID in string format</param>
479
/// <param name="userName">login username</param>
480
/// <param name="password">login password</param>
481
/// <param name="mPage"></param>
482
/// <param name="publish"></param>
483
/// <returns></returns>
484
internal string NewPage(string blogID, string userName, string password, MWAPage mPage, bool publish)
485
...{
486
ValidateRequest(userName, password);
487
488
Page page = new Page();
489
page.Title = mPage.title;
490
page.Content = mPage.description;
491
if (mPage.pageDate != new DateTime())
492
page.DateCreated = mPage.pageDate.AddHours(BlogSettings.Instance.Timezone * -1); ;
493
page.ShowInList = publish;
494
page.IsPublished = publish;
495
if (mPage.pageParentID != "0")
496
page.Parent = new Guid(mPage.pageParentID);
497
498
page.Save();
499
500
return page.Id.ToString();
501
}
502
503
/**//// <summary>
504
/// wp.getPages
505
/// </summary>
506
/// <param name="blogID">blogID in string format</param>
507
/// <param name="userName">login username</param>
508
/// <param name="password">login password</param>
509
/// <returns></returns>
510
internal List<MWAPage> GetPages(string blogID, string userName, string password)
511
...{
512
ValidateRequest(userName, password);
513
514
List<MWAPage> pages = new List<MWAPage>();
515
516
foreach (Page page in Page.Pages)
517
...{
518
MWAPage mPage = new MWAPage();
519
mPage.pageID = page.Id.ToString();
520
mPage.title = page.Title;
521
mPage.description = page.Content;
522
mPage.pageDate = page.DateCreated;
523
mPage.link = page.AbsoluteLink.AbsoluteUri;
524
mPage.mt_convert_breaks = "__default__";
525
mPage.pageParentID = page.Parent.ToString();
526
527
pages.Add(mPage);
528
}
529
530
return pages;
531
}
532
533
/**//// <summary>
534
/// wp.getPage
535
/// </summary>
536
/// <param name="blogID">blogID in string format</param>
537
/// <param name="pageID">page guid in string format</param>
538
/// <param name="userName">login username</param>
539
/// <param name="password">login password</param>
540
/// <returns>struct with post details</returns>
541
internal MWAPage GetPage(string blogID, string pageID, string userName, string password)
542
...{
543
ValidateRequest(userName, password);
544
545
MWAPage sendPage = new MWAPage();
546
Page page = Page.GetPage(new Guid(pageID));
547
548
sendPage.pageID = page.Id.ToString();
549
sendPage.title = page.Title;
550
sendPage.description = page.Content;
551
sendPage.pageDate = page.DateCreated;
552
sendPage.link = page.AbsoluteLink.AbsoluteUri;
553
sendPage.mt_convert_breaks = "__default__";
554
if (page.Parent != null)
555
sendPage.pageParentID = page.Parent.ToString();
556
557
return sendPage;
558
}
559
560
internal bool EditPage(string blogID, string pageID, string userName, string password, MWAPage mPage, bool publish)
561
...{
562
ValidateRequest(userName, password);
563
564
Page page = Page.GetPage(new Guid(pageID));
565
566
page.Title = mPage.title;
567
page.Content = mPage.description;
568
page.ShowInList = publish;
569
page.IsPublished = publish;
570
if (mPage.pageParentID != "0")
571
page.Parent = new Guid(mPage.pageParentID);
572
573
page.Save();
574
575
return true;
576
}
577
578
internal bool DeletePage(string blogID, string pageID, string userName, string password)
579
...{
580
ValidateRequest(userName, password);
581
try
582
...{
583
Page page = Page.GetPage(new Guid(pageID));
584
page.Delete();
585
page.Save();
586
}
587
catch (Exception ex)
588
...{
589
throw new MetaWeblogException("15", "DeletePage failed. Error: " + ex.Message);
590
}
591
592
return true;
593
}
594
595
#endregion
596
597
Private Methods#region Private Methods
598
599
/**//// <summary>
600
/// Checks username and password. Throws error if validation fails.
601
/// </summary>
602
/// <param name="userName"></param>
603
/// <param name="password"></param>
604
private void ValidateRequest(string userName, string password)
605
...{
606
if (!Membership.ValidateUser(userName, password))
607
...{
608
throw new MetaWeblogException("11", "User authentication failed");
609
}
610
}
611
612
/**//// <summary>
613
/// Returns Category Guid from Category name.
614
/// </summary>
615
/// <remarks>
616
/// Reverse dictionary lookups are ugly.
617
/// </remarks>
618
/// <param name="name"></param>
619
/// <param name="cat"></param>
620
/// <returns></returns>
621
private bool LookupCategoryGuidByName(string name, out Category cat)
622
...{
623
cat = new Category();
624
foreach (Category item in Category.Categories)
625
...{
626
if (item.Title == name)
627
...{
628
cat = item;
629
return true;
630
}
631
}
632
return false;
633
}
634
635
#endregion
636
}
637
638
/**//// <summary>
639
/// Exception specifically for MetaWeblog API. Error (or fault) responses
640
/// request a code value. This is our chance to add one to the exceptions
641
/// which can be used to produce a proper fault.
642
/// </summary>
643
[Serializable()]
644
public class MetaWeblogException : Exception
645
...{
646
/**//// <summary>
647
/// Constructor to load properties
648
/// </summary>
649
/// <param name="code">Fault code to be returned in Fault Response</param>
650
/// <param name="message">Message to be returned in Fault Response</param>
651
public MetaWeblogException(string code, string message)
652
: base(message)
653
...{
654
_code = code;
655
}
656
657
private string _code;
658
/**//// <summary>
659
/// Code is actually for Fault Code. It will be passed back in the
660
/// response along with the error message.
661
/// </summary>
662
public string Code
663
...{
664
get ...{ return _code; }
665
}
666
}
667
668
/**//// <summary>
669
/// MetaWeblog Category struct
670
/// returned as an array from GetCategories
671
/// </summary>
672
internal struct MWACategory
673
...{
674
/**//// <summary>
675
/// Category title
676
/// </summary>
677
public string description;
678
/**//// <summary>
679
/// Url to thml display of category
680
/// </summary>
681
public string htmlUrl;
682
/**//// <summary>
683
/// Url to RSS for category
684
/// </summary>
685
public string rssUrl;
686
/**//// <summary>
687
/// The guid of the category
688
/// </summary>
689
public string id;
690
/**//// <summary>
691
/// The title/name of the category
692
/// </summary>
693
public string title;
694
}
695
696
/**//// <summary>
697
/// MetaWeblog BlogInfo struct
698
/// returned as an array from getUserBlogs
699
/// </summary>
700
internal struct MWABlogInfo
701
...{
702
/**//// <summary>
703
/// Blog Url
704
/// </summary>
705
public string url;
706
/**//// <summary>
707
/// Blog ID (Since BlogEngine.NET is single instance this number is always 10.
708
/// </summary>
709
public string blogID;
710
/**//// <summary>
711
/// Blog Title
712
/// </summary>
713
public string blogName;
714
}
715
716
/**//// <summary>
717
/// MetaWeblog Fault struct
718
/// returned when error occurs
719
/// </summary>
720
internal struct MWAFault
721
...{
722
/**//// <summary>
723
/// Error code of Fault Response
724
/// </summary>
725
public string faultCode;
726
/**//// <summary>
727
/// Message of Fault Response
728
/// </summary>
729
public string faultString;
730
}
731
732
/**//// <summary>
733
/// MetaWeblog MediaObject struct
734
/// passed in the newMediaObject call
735
/// </summary>
736
internal struct MWAMediaObject
737
...{
738
/**//// <summary>
739
/// Name of media object (filename)
740
/// </summary>
741
public string name;
742
/**//// <summary>
743
/// Type of file
744
/// </summary>
745
public string type;
746
/**//// <summary>
747
/// Media
748
/// </summary>
749
public byte[] bits;
750
}
751
752
/**//// <summary>
753
/// MetaWeblog MediaInfo struct
754
/// returned from NewMediaObject call
755
/// </summary>
756
internal struct MWAMediaInfo
757
...{
758
/**//// <summary>
759
/// Url that points to Saved MediaObejct
760
/// </summary>
761
public string url;
762
}
763
764
/**//// <summary>
765
/// MetaWeblog Post struct
766
/// used in newPost, editPost, getPost, recentPosts
767
/// not all properties are used everytime.
768
/// </summary>
769
internal struct MWAPost
770
...{
771
/**//// <summary>
772
/// PostID Guid in string format
773
/// </summary>
774
public string postID;
775
/**//// <summary>
776
/// Title of Blog Post
777
/// </summary>
778
public string title;
779
/**//// <summary>
780
/// Link to Blog Post
781
/// </summary>
782
public string link;
783
/**//// <summary>
784
/// Content of Blog Post
785
/// </summary>
786
public string description;
787
/**//// <summary>
788
/// List of Categories assigned for Blog Post
789
/// </summary>
790
public List<string> categories;
791
/**//// <summary>
792
/// List of Tags assinged for Blog Post
793
/// </summary>
794
public List<string> tags;
795
/**//// <summary>
796
/// Display date of Blog Post (DateCreated)
797
/// </summary>
798
public DateTime postDate;
799
/**//// <summary>
800
/// Whether the Post is published or not.
801
/// </summary>
802
public bool publish;
803
/**//// <summary>
804
/// Slug of post
805
/// </summary>
806
public string slug;
807
/**//// <summary>
808
/// CommentPolicy (Allow/Deny)
809
/// </summary>
810
public string commentPolicy;
811
/**//// <summary>
812
/// Excerpt
813
/// </summary>
814
public string excerpt;
815
816
}
817
818
/**//// <summary>
819
/// MetaWeblog UserInfo struct
820
/// returned from GetUserInfo call
821
/// </summary>
822
/// <remarks>
823
/// Not used currently, but here for completeness.
824
/// </remarks>
825
internal struct MWAUserInfo
826
...{
827
/**//// <summary>
828
/// User Name Proper
829
/// </summary>
830
public string nickname;
831
/**//// <summary>
832
/// Login ID
833
/// </summary>
834
public string userID;
835
/**//// <summary>
836
/// Url to User Blog?
837
/// </summary>
838
public string url;
839
/**//// <summary>
840
/// Email address of User
841
/// </summary>
842
public string email;
843
/**//// <summary>
844
/// User LastName
845
/// </summary>
846
public string lastName;
847
/**//// <summary>
848
/// User First Name
849
/// </summary>
850
public string firstName;
851
}
852
853
/**//// <summary>
854
/// wp Page Struct
855
/// </summary>
856
internal struct MWAPage
857
...{
858
/**//// <summary>
859
/// PostID Guid in string format
860
/// </summary>
861
public string pageID;
862
/**//// <summary>
863
/// Title of Blog Post
864
/// </summary>
865
public string title;
866
/**//// <summary>
867
/// Link to Blog Post
868
/// </summary>
869
public string link;
870
/**//// <summary>
871
/// Content of Blog Post
872
/// </summary>
873
public string description;
874
/**//// <summary>
875
/// Display date of Blog Post (DateCreated)
876
/// </summary>
877
public DateTime pageDate;
878
/**//// <summary>
879
/// Convert Breaks
880
/// </summary>
881
public string mt_convert_breaks;
882
/**//// <summary>
883
/// Page Parent ID
884
/// </summary>
885
public string pageParentID;
886
}
887
888
}