Hello, the following code demonstrates how to automatically post content to Blogspot using PHP code. This code enables you to post content to your Blogspot blog directly from your application, which can be particularly useful when sharing links or content on social sites.

Efficiency in the world of blogging is paramount, and automating the process of posting content can significantly enhance productivity. In this article, we will delve into the world of auto-posting into Blogspot using PHP code. By the end of this guide, you’ll have a comprehensive understanding of how to streamline your blogging workflow and automatically publish content to your Blogspot blog. Whether you’re a professional blogger or maintaining a personal website, automating blog posts can save you time and make your content publishing process more efficient.

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 = "[email protected]";
    $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.

In conclusion, automating blog post submissions to Blogspot using PHP code offers bloggers and website owners a powerful tool to streamline their content publishing workflow. The ability to seamlessly schedule and post content from their applications not only saves time but also ensures a consistent and efficient content strategy. Whether you’re sharing links or posting content on social sites, this method simplifies the process, making it an indispensable asset in the digital age.

By mastering the techniques described in this article, bloggers and content creators can maintain a dynamic online presence with minimal effort. The automation of blog post submissions not only enhances productivity but also allows for a more organized and strategic approach to content sharing. With this newfound knowledge, bloggers can take full advantage of the capabilities offered by PHP code to achieve a more efficient and effective blogging experience, meeting the demands of the fast-paced digital landscape.


41 Comments

nickace · November 26, 2009 at 10:53 pm

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

Anil Kumar Panigrahi · November 27, 2009 at 2:54 am

Most welcome …

harry · January 5, 2010 at 11:38 am

Thanks its helpfull… but How to set the label?

azzaam · January 6, 2010 at 11:54 pm

where i set the code?

Anil Kumar Panigrahi · January 7, 2010 at 2:57 am

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.

mizake · February 1, 2010 at 3:14 pm

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..?

Anil Kumar Panigrahi · February 2, 2010 at 2:54 am

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.

hacobi1102 · February 6, 2010 at 8:17 am

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 · February 6, 2010 at 8:23 am

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!

Esaul Daris · April 13, 2010 at 7:40 am

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.

Marcus · October 24, 2010 at 2:54 pm

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

Anil Kumar Panigrahi · October 26, 2010 at 6:20 pm

@Marcus

You can run from your localhost with your credentials but in your apache support CURL package.

tv izle · November 26, 2010 at 3:02 pm

Thank you very much and the timing is good, I am just…

upul suresh · June 5, 2011 at 1:15 am

Thank a lot

Your above coding I used and work properly in http://buyandsell-srilanka.blogspot.com

Thank you very much

Krishna · September 24, 2012 at 6:56 am

Hello, Nice article and very useful .

Thanks

KIran · October 4, 2012 at 4:17 pm

Hello,
Nice article . I think there is a limit in blogger on number of automated posts / day .
Here is a simple tool for sending rss/atom feeds content to multiple blogger.com accounts in single click .

Thanks

Surinder · February 28, 2013 at 4:06 pm

I have curl enabled server but this code doesn’t work for me 🙁
my blog is : http://thebloggingtricks.blogspot.com/
it returned this :

bool(false)
Array
(
[url] => https://www.blogger.com/feeds/3139338840219246749/posts/default
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 428
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 4.000643
[namelookup_time] => 0.002279
[connect_time] => 0.00992
[pretransfer_time] => 0.037535
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 2.037611
[redirect_time] => 0
[certinfo] => Array
(
)

[redirect_url] =>
)

    masoud · May 1, 2017 at 11:59 am

    Hi Surinder
    I have the same issue. did you find any solution

gopi · March 9, 2013 at 6:36 am

NIce Article.

gopi · March 9, 2013 at 7:59 am

good

divyesh · April 15, 2013 at 12:54 pm

i use your code but i have one problem when my page load it display all element but $token = $arr[3]; was every time empty so how to solve this pro..

all element detail ===

Array
(
[0] => Content-type: application/atom+xml
[1] => Content-Length: 160
[2] => Authorization: GoogleLogin auth=
[3] =>

123 magic.

)
bool(false)
Array
(
[url] => https://www.blogger.com/feeds/6629929181202825897/posts/default
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 369
[filetime] => -1
[ssl_verify_result] => 20
[redirect_count] => 0
[total_time] => 4.29
[namelookup_time] => 0
[connect_time] => 0.094
[pretransfer_time] => 0.281
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 1.295
[redirect_time] => 0
)

so plz help me

parth patel · June 7, 2013 at 9:27 am

hello bro will u help me to develop admin panel for my web site..??

vinayak · September 11, 2013 at 6:23 am

is it possible to share without using password?

chris · April 11, 2015 at 11:42 am

Hello,

How to get content from other website using curl and then autopost the result to blogspot ?

thanks
chris

Sanjay Samanta · October 27, 2015 at 12:12 pm

hello ,
I used your code but i have faced the problem. My code out put as

Array
(
[0] => Content-type: application/atom+xml
[1] => Content-Length: 204
[2] => Authorization: Google Login auth=viewport content
[3] =>

This is testing contnet to post in blog post.

)
bool(false)

PHP training institute · May 24, 2016 at 10:53 am

Awesome post!!! Thanks for sharing information about PHP courses and PHP classes. This blog post looking interesting. Very useful information. Good going. http://goo.gl/IoIakF

nandhini seo · June 13, 2016 at 9:12 am

Your site is very informative and your articles are wonderful.

سوق · February 27, 2017 at 3:39 am

i hope that it’s still working
thanks

vamshikrishna · March 22, 2017 at 12:56 pm

Nice to read your article! very informative.So, please keep posting Useful Stuff here Thanks….

vadivel · April 11, 2017 at 1:50 am

Nice Post, Php problems and Solutions

Vadivels · April 23, 2017 at 1:10 pm

Hey Very nice article, you want any hd wallpapers.

Vadivels · April 23, 2017 at 1:13 pm

Hey Very nice article, you want any hd wallpapers. http://imgcluster.com

Atul Srivastava · April 24, 2017 at 7:57 am

Hey Nice blog,Thanks for sharing this blog.!!!

Best python training in lucknow

Best Php training in lucknow

best summer training company in lucknow

dheeraj sharma · June 6, 2017 at 7:40 pm

great post

PHP Classes · July 5, 2017 at 11:21 am

Hello, Thank you much I am looking for this from some days. It is very heipful. PHP Classes!

seo training in nagpur · July 5, 2017 at 6:27 pm

Nice Post, Php problems and Solutions

pranjali · August 10, 2017 at 5:46 pm

Thanks for sharing such a source of information. which is important in web development.

sheetal sharma · January 22, 2018 at 9:21 am

Nice article,
This article is really good and also contains sufficient information
thanks for sharing

taiyari · January 5, 2024 at 8:06 am

nice article.

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *