one of my friends gave me this code for blogger posting using php. but it's not working. my server already have cURL
<?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;
?>
when i run this code. getting result like this
Array ( [0] => Content-type: application/atom+xml [1] => Content-Length: 208 [2] => Authorization: GoogleLogin auth= [3] =>
This is testing contnetto post in blog post.
) bool(false) Array ( [url] => https://www.blogger.com/feeds/7493633362314585130/posts/default [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 417 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 4.001117 [namelookup_time] => 0.001279 [connect_time] => 0.007472 [pretransfer_time] => 0.026912 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 1.028038 [redirect_time] => 0 [certinfo] => Array ( )
[redirect_url] =>
)
blogger won't posing anything . can you help me to fix this code
and sorry for my English