$postTitle = 'post test';
$postContent = 'just another test.';
$url = 'https://www.googleapis.com/blogger/v3/blogs/'.$blogId.'/posts/';
$headerQuery = array();
$headerQuery[] = 'Authorization: '.$accessToken;
$headerQuery[] = 'Content-Type: application/json';
$headerQuery[] = ' { "kind": "blogger#post", "blog": {"id": "'.$blogId.'"}, "title": "'.$postTitle.'", "content": "'.$postContent.'" }';
//$headerQuery[] = 'Content-length: '.strlen($headerQuery[2]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerQuery);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$data = curl_exec($ch);
echo $data;
//echo curl_errno($ch);
$response = json_decode($data);
echo "url: " . $response->url."
";
echo "id: " . $response->id."
";
curl_close($ch);
0 Post a Comment :
Post a Comment