Auto Post On Blogspot Using PHP script

Auto Post On Blogspot Using PHP script

Today, We want to share with you Auto Post On Blogspot Using PHP script.
In this post we will show you Automatically Post Content To Blogspot Using PHP, hear for Automatically post to a Blogspot page using the Blogspot PHP API we will give you demo and example for implement.
In this post, we will learn about Automatically Post Content To Blogspot Using PHP with an example.

How to Auto Post on Blogspot with PHP Example

This Offical document Learn how to get step by step How to Auto Post on Blogspot with PHP started using the Blogger API.Blogger API

//Dynemic generate return URL
$redirct_url = "https://".$_SERVER["HTTP_HOST"].$_SERVER['PHP_SELF'];
//include all libs using google
require_once 'google-api-php-client-master/src/Google/autoload.php'; 

$google_clnt = new Google_Client();
$google_clnt->setApplicationName("PakaInfo");
$google_clnt->setDeveloperKey("Ahdjhjdfid554dDDDkjkjkk52-25sdjs20dddKsjhdd5");

$google_clnt->setAccessType('online');
$google_clnt->setClientId("988995555356-9898kasjdjdibmi55ss1bk94plhu58Dioene.apps.googleusercontent.com");
$google_clnt->setClientSecret("82cVvhOy5z3hsW2Ur4fgdfg8QXaBR");
$google_clnt->setRedirectUri($redirct_url);
$google_clnt->setScopes(array('https://www.googleapis.com/auth/blogger')); //since we are going to use blogger services

$bloggerService = new Google_Service_Blogger($google_clnt);

if (isset($_GET['logout'])) { // Google logout: Your destroy token
unset($_SESSION['token']);
 die('Good Luck Logged out.');
}

if (isset($_GET['code'])) { // we get the positive google auth callback, get the simple google auth token and some store it in session
	$google_clnt->authenticate($_GET['code']);
	$_SESSION['token'] = $google_clnt->getAccessToken();
}

if (isset($_SESSION['token'])) { // extract get token from session and configure google_clnt
	$get_token = $_SESSION['token'];
	$google_clnt->setAccessToken($get_token);
}

if (!$google_clnt->getAccessToken()) { // Your auth call to google
	$authUrl = $google_clnt->createAuthUrl();
	header("Location: ".$authUrl);
	die;
}

$posts = $bloggerService->posts;

$LivePost = new Google_Service_Blogger_Post();
$LivePost->setTitle("WRITE_YOUR_POST_TITLE ".time());
$LivePost->setLabels("WRITE_YOUR_POST_LABEL");
$LivePost->setContent("WRITE_YOUR_POST_CONTENT!!!!");
$LivePost->setCustomMetaData("YOUR_CUSTOM_META_DATA ".time());

try
{
	$nposts = $posts->insert("4842995321113595808",$LivePost);
}
catch(Exception $e)
{
	//generate Error
   print_r($e);
}
	

Auto Post to Blogger with Title , post label and search some description using Blogger PHP Script API v 3.0

Also Read :  How to Quickly Index New Post In Google Search

And then this post, After that We logged into blogger on Google Product. I can display the above post title and description there. With this auto post has successfully upload ‘Post Title’ as well as ‘Post Body’.

Adding a post : Auto Post On Blogspot Using PHP

We can Simple Add an Auto post for a google product blog by sending a POST All the data request to the using post Methods collection URL with a post Simple JSON body:

https://www.googleapis.com/blogger/v3/blogs/blogId/posts/

Auto Post On Blogspot Using PHP : Request

POST https://www.googleapis.com/blogger/v3/blogs/4842995321113595808/posts/
Authorization: /* get here Google OAuth 2.0 token here */
Content-Type: application/json

{
  "kind": "blogger#post",
  "blog": {
    "id": "4842995321113595808"
  },
  "title": "My First Auto Post On Blogspot Using PHP Example ",
  "content": "Welcome <h2>pakainfo.com</h2> You Are Always Welcome..."
}

We must be Google authenticated to Add a Auto post on The Google Blogger.

Also Read :  Top 10 Ways to Increase Google Adsense Earnings

We hope you get an idea about Auto post into Blogspot using php Source code
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.

We hope This Post can help you…….Good Luck!.

Recommended For You.

How to Open URL in New Tab using ASP.NET Today, We want to share with you How to Open URL in