In this post we will learn how to programmatically post to blogger, we use PHP for this but it can be done in any language which can send email. When we talk about programmatically, usually some complex programming scheme comes into mind but in this case there is no such thing, although one can use Blogger's PHP API or Blogger API for JAVA, but here we use simple mail to do this. First you need to configure your blogger account, open your blogger account and go to Setting -> Mobile and email as shown in figure below...
in the Email section create an email which is your secret email address (do not share it with any one, mine show is figure is fake ;) ), this is used for creating blog post and set the option to your choice either you want it to publish immediately or save it as draft and then you approve it in future, in example i set publish immediately, after that click save settings and you blogger account is configured.
now create a simple PHP script that will send the mail and your post is automatically publish on blogger. A simple PHP code will be like this...
<?php function sendPostToBlogger($postTitle,$postBody){ // our secret mail address we just created $mailAddress="tutorialjinni.auto@blogger.com"; // using PHP mail function mail($mailAddress,$postTitle,$postBody); } ?>
and that is it... you can configure this is some sort of cron job or set it as a trigger in you code or as you wish :)
*Note You can pass HTML in $postBody too...
4 comments:
Please explain what is the purpose of using this coding? Where to include it?
SAS Job Openings
php requires hosting, where to upload the php code?
regards,
Best Cover Song
google "free php hosting" and you will find one.
i will not recommend any free hosting because i believe in "There ain't no such thing as a free lunch"
Is still work now?
Post a Comment