Blogging and News Syndication Software

Blogger API, RSS API, Atom API, and more.
posts - 17, comments - 14, trackbacks - 26

My Links

News

Tortuga Components / Software Tools Home

See Also: Chilkat Software

Article Categories

Archives

Post Categories

Recommended

MetaWeblog API .NET: Post with Image

C# example code using the Tortuga MetaWeblog .NET API to create a post with an image. The image (GIF file) is uploaded from the local filesystem to the blog server.
The Tortuga Beta .NET Component can be downloaded from MetaWeblog .NET
The download contains an .NET class library (DLL) that needs to be referenced from your C# or VB.NET project.

// Use the Blogger 1.0 API to get the Blog ID
Tortuga.Blogger1 blogger1 = new Tortuga.Blogger1();
    
blogger1.Login = "tortuga";
blogger1.Password = "password";
blogger1.ServiceUrl = "http://www.squarespace.com/do/process/external/PostInterceptor";
    
bool success = blogger1.GetUsersBlogs();
if (!success || (blogger1.NumBlogs == 0)) return;

string blogId = blogger1.GetBlogId(0);

Tortuga.MetaWeblog mwlog = new Tortuga.MetaWeblog();

// Use MetaWeblog to create a new post
mwlog.Login = "tortuga";
mwlog.Password = "password";
mwlog.ServiceUrl = "http://www.squarespace.com/do/process/external/PostInterceptor";

// Upload an image to the blog server
string localFilename = "c:/images/dude.gif";
string remoteFilename = "cool.gif";
string imageUrl = mwlog.NewMediaObject(blogId,localFilename,remoteFilename);
		
MessageBox.Show(imageUrl);

string postId;
bool publish = true;
string htmlContent = "This is a post with an image: <img src=\"" + imageUrl + "\">";
string title = "Post with image";
postId = mwlog.NewPost(blogId, title, htmlContent, publish);

MessageBox.Show("This ID of the post created = " + postId);


Print | posted on Sunday, September 25, 2005 1:01 PM |

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 

Powered by: