Post a new Post in Blog using C#

[email protected]
Newsgroups gmane.comp.web.blogger.api
Message-ID <[email protected]>
Hi,


   I m Trying to add a post in my wordpress account using c# Coding but i m 
Getting *"Execution of authentication request returned unexpected result: 
404"*


  private static int AddPost(string title = "", string html = "", string[] 
labels = null, string user = "", string pass = "", string blogUrl = "", 
bool isDraft = false)
        {


            try
            {

                //Is needed to bypass a certificare error
                ServicePointManager.ServerCertificateValidationCallback =
                    new RemoteCertificateValidationCallback
                    (
                        delegate { return true; }
                    );


                Service service = new Service("blogger", 
"googleAPIshittyName");
                service.Credentials = new GDataCredentials("****", "****");
                var token =service.QueryAuthenticationToken();
                service.SetAuthenticationToken(token);
                GDataGAuthRequestFactory factory = 
(GDataGAuthRequestFactory)service.RequestFactory;
                factory.AccountType = "GOOGLE";

                //Create a blog article
                AtomEntry newPost = new AtomEntry();

                //Set blog post's title
                newPost.Title.Text = "Bashur";

                //Create blog post's content
                newPost.Content = new AtomContent();

                //Replace "new lines" with <br />
                string[] breaks = new string[] { "rn", "r", "n" };
                foreach (string breakStr in breaks)
                {
                    while (html.Contains(breakStr))
                        html = html.Replace(breakStr, "<br/>");
                }
                newPost.Content.Content = "Testing Blog";
                newPost.Content.Type = "html";

                //Set up tags/labels
                labels = null;
                ////foreach (string labelRaw in labels)
                ////{
                ////    AtomCategory cat = new AtomCategory();
                ////    cat.Scheme = new 
Uri("http://www.blogger.com/atom/ns#");

                ////    string label = labelRaw;
                ////    string[] forbiddenChars = new string[] { "&", "<", 
">", "@", "!", "," };
                ////    foreach (string forbiddenChar in forbiddenChars)
                ////    {
                ////        while (label.Contains(forbiddenChar))
                ////            label = label.Replace(forbiddenChar, "");
                ////    }
                ////    cat.Term = label;
                ////    newPost.Categories.Add(cat);
                ////}



                AtomCategory cat = new AtomCategory();
                //cat.Scheme = new Uri("https://wordpress.com/posts/");
           cat.Scheme = new Uri(" http://www.blogger.com/atom/ns#");
                newPost.Categories.Add(cat);

                newPost.IsDraft = false;

                AtomEntry response = null;
                try
                {
                    //Post article
                    response = service.Insert(new 
Uri("http://dotnetmvcblog.wordpress.com"), newPost);
                }
                catch (GDataRequestException iDontCare)
                {
                    if (iDontCare.ResponseString == "Blog has exceeded rate 
" +
                                            "limit or otherwise requires 
word " +
                                        "verification for new posts")
                    {
                        //This error happens if you have exceeded your 
daily post limit
                        return -2;
                    }
                    else
                    {
                        //Another error
                        throw iDontCare;
                    }
                }
                if (response == null)
                {
                    throw new Exception("Can't create connection.");
                }

                //Blog post successful added to blog
                return 0;
            }
            catch
            {
                return -1;
            }
        }


Please help me in this as early as possible

Thanks & Regards,
SD.BASHUR

-- 
You received this message because you are subscribed to the Google Groups "Blogger Developer Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/bloggerdev.
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.