PDA

View Full Version : حرفه ای: ارسال خودکار مطلب از سایت به گوگل پلاس



mohan21
یک شنبه 01 آذر 1394, 14:52 عصر
با سلام

برای ارسال مطالبم از سایت به گوگل پلاس از کد زیر با curl استفاده کردم، اما خطای 301 میدهد.



$clientlogin_url = "https://www.google.com/accounts/ClientLogin";
$clientlogin_post = array(
"accountType" => "HOSTED_OR_GOOGLE",
"Email" => "my-gmail@gmail.com",
"Passwd" => "my-password",
"service" => "writely",
"source" => "your application name");
// Initialize the curl object
$curl = curl_init($clientlogin_url);
// Set some options (some for SHTTP)
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $clientlogin_post);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// Execute
$response = curl_exec($curl);
// Get the Auth string and save it
preg_match("/Auth=([a-z0-9_-]+)/i", $response, $matches);
$auth = $matches[1];
$params['newcontent'] = "Post on Google Plus Test By Me";
$headers = array( "Authorization: GoogleLogin auth=" . $auth, "GData-Version: 3.0",);// Make the request
curl_setopt($curl, CURLOPT_URL, 'https://www.plus.google.com/');
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($curl);
var_dump($response);
curl_close($curl);

آیا راه دیگری برای ارسال مطالب وجود دارد؟