Re: [php] i can't post new posts to my blogger
Laio sen <[email protected]>
| Newsgroups | gmane.comp.web.blogger.api |
|---|---|
| Message-ID | <[email protected]> |
I find the reason, because the curl will go ask the correctness openssl
website, it will be stuck in the inquiry period
Then just close the inquiry action.
php code change like this:
<?php
$arr['api_key'] = {api key};
$arr['token_id'] = {token};
$arr['blog_id'] = {blogger id};
$arr['tag'] = {tag};//like: test,google,blogger
$arr['title'] = {title};
$arr['content']= {content};
function post_in($arr){
$to['url'] =
"https://www.googleapis.com/blogger/v3/blogs/".$arr['blog_id']."/posts?fields=id&key=".$arr['api_key'];
$to['hand'] = array("Authorization: Bearer
".$arr['token_id'],"Content-Type: application/json");
$to['content'] = array(
"blog"=>array( "id"=>$arr['blog_id']),
"title"=>$arr['title'],
'labels'=>explode (',',$arr['tag']),
"content"=>$arr['content']
);
$to['content']=json_encode($to['content']);
$re = blogger_add($to);
$temp = json_decode($re);
return $temp->id;
}
function blogger_add($arr){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $arr['url']);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $arr['hand']);
curl_setopt($ch, CURLOPT_POSTFIELDS ,$arr['content']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
$re = curl_exec($ch);
curl_close($ch);
return $re;
}
?>
--
You received this message because you are subscribed to the Google Groups "Blogger Developer Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/bloggerdev.
For more options, visit https://groups.google.com/groups/opt_out.