Hi, the following code will help to auto post into blogspot using php code. We can post into blogspot blog from your application by this code. It will be useful when we post one link or some content to post into social sites from your application then we can use this code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | <?php session_start(); $email = "blogger_email@gmail.com"; $pass = "password"; $blogID= urlencode("blogger_id"); // like 6304924319904337556 // Do Not Modify Below Code if(!isset($_SESSION['sessionToken'])) { $ch = curl_init("https://www.google.com/accounts/ClientLogin?Email=$email&Passwd=$pass&service=blogger&accountType=GOOGLE"); curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1); curl_setopt($ch, CURLOPT_HEADER,0); curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); $result = curl_exec($ch); $resultArray = curl_getinfo($ch); curl_close($ch); $arr = explode("=",$result); $token = $arr[3]; $_SESSION['sessionToken'] = $token; } $entry = "<entry xmlns='http://www.w3.org/2005/Atom'> <title type='text'>Title of blog post </title> <content type='xhtml'> This is testing contnetto post in blog post. </content> </entry>"; $len = strlen($entry); $headers = array("Content-type: application/atom+xml","Content-Length: {$len}","Authorization: GoogleLogin auth={$_SESSION['sessionToken']}","$entry"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://www.blogger.com/feeds/$blogID/posts/default"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 4); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1); curl_setopt($ch, CURLOPT_POST, true); $result = curl_exec($ch); $ERROR_CODE = curl_getinfo($ch); curl_close($ch); echo '<pre>'; print_r($headers); var_dump($result); print_r($ERROR_CODE); exit; ?> |
Hope that it will be useful.
Thank you,








Hey Thank you very much, and the timing is good, I am just looking for this.
but I have tried it everthing works but My post did not appear, what do you think is wrong
Thnks
Most welcome …
Thanks its helpfull… but How to set the label?
where i set the code?
Hello azzam,
Title of blog post
This is testing contnetto post in blog post.
In this code we have to change the what you want to post into your blogspot.
and run this file at at http://localhost/blogpost.php , if you save the file blogpost.php, hope you understand.
Hi thank you..for this great info
one question..can I attach this code into classic template since a blogger classic template is work with php code..?
Hi mizake,
This script will work for post content into blogger, using php code. , for that you should have curl support php version., if it is available then with this code you can post the content into blogspot blogger.
This is work very good!
Thank you
Can you give me your Yahoo ID?
Please PM me with my Yahoo ID: ng0ngan.viyeu
I have some ask with this code
I want to u this get RSS content and post to blogspot !
Thank you very much!
that is my blog use this code: http://masterbaunet.blogspot.com/
And link to code: http://hacobi.com/test/blogger.php
Im added function time() in title of post
This is work very good!
Thank you
Can you give me your Yahoo ID?
Please PM me with my Yahoo ID: ng0ngan.viyeu
I have some ask with this code
I want to u this get RSS content and post to blogspot !
Thank you very much!
hacobi1102,
both of your blog was not found. One of them was banned by google. Is that meaned google not agreed with every automatic post with any trick?
I need your reply, or Anil reply.
regards,
Esaul Daris.
Hi Anil,
I don’t have my personal server. So do you have any idea how to execute your code. Perhaps any free php hosting site or can I execute your code on my windows based computer when I am online? Thanks
Regards,
Marcus
@Marcus
You can run from your localhost with your credentials but in your apache support CURL package.
Thank you very much and the timing is good, I am just…
Thank a lot
Your above coding I used and work properly in http://buyandsell-srilanka.blogspot.com
Thank you very much