gayan balasooriya gayan balasooriya - 1 year ago 234
PHP Question

google api v3 blogger post insert php ajax

I have tried to get blogger blog info by using the api.

$blogger = new Google_BloggerService($client);
$data = $blogger->blogs->getByUrl(array('url'=>''));

and it worked fine and gave me the details.

then I tried to insert a post as below


$token = json_decode($token, true); //already got the token

<script src="//"></script>
url: "",
Authorization: "OAuth <?php echo $token['access_token']; ?>",
data: {"kind": "blogger#post",
"blog": {
"id": "555555555555555"
"title": "A new post",
"content": "With <b>exciting</b> content..."},
dataType: 'json',
contentType: 'application/json',


but it gives me

"error": {
"errors": [
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
"code": 401,
"message": "Login Required"

please help me to insert a post to blogger blog through api v3 using php.

Answer Source

It was simple than I was trying to post on blogger. I am presenting here only the php code that does the post and it was working fine for me.

$blogger = new Google_BloggerService($client);    
$mypost = new Google_Post();
$mypost->setTitle('this is a test 1 title');
$mypost->setContent('this is a test 1 content');
$data = $blogger->posts->insert('5555555555555555555', $mypost);


full detailed posting is at

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download