Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PHP Curl在Google Plus上发布状态_Php_Curl_Google Plus - Fatal编程技术网

使用PHP Curl在Google Plus上发布状态

使用PHP Curl在Google Plus上发布状态,php,curl,google-plus,Php,Curl,Google Plus,我有这段代码,用于使用带有curl的简单DOM解析器登录Google。我尝试使用以下代码在google plus上发布状态,但无法在google plus上发布 有没有办法解决这个问题 以下是我的代码供参考: $clientlogin_url = "https://www.google.com/accounts/ClientLogin"; $clientlogin_post = array( "accountType" => "HOSTED_OR_GOOGLE", "Ema

我有这段代码,用于使用带有curl的简单DOM解析器登录Google。我尝试使用以下代码在google plus上发布状态,但无法在google plus上发布

有没有办法解决这个问题

以下是我的代码供参考:

$clientlogin_url = "https://www.google.com/accounts/ClientLogin";
$clientlogin_post = array(
    "accountType" => "HOSTED_OR_GOOGLE",
    "Email" => "youremail@gmail.com",
    "Passwd" => "yourpassword",
    "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);

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

感谢您的帮助和合作

您也需要在此处添加这两个
cURL
参数

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); //Added here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //Added here
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // Since you got 301 redirect
此外,您没有在代码上输出任何响应

$response = curl_exec($curl);
var_dump($response);// Added here
curl_close($curl);

您还需要在此处添加这两个
cURL
参数

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); //Added here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //Added here
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // Since you got 301 redirect
此外,您没有在代码上输出任何响应

$response = curl_exec($curl);
var_dump($response);// Added here
curl_close($curl);

您还需要在此处添加这两个
cURL
参数

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); //Added here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //Added here
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // Since you got 301 redirect
此外,您没有在代码上输出任何响应

$response = curl_exec($curl);
var_dump($response);// Added here
curl_close($curl);

您还需要在此处添加这两个
cURL
参数

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); //Added here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //Added here
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // Since you got 301 redirect
此外,您没有在代码上输出任何响应

$response = curl_exec($curl);
var_dump($response);// Added here
curl_close($curl);

没有Google+API来发布状态(除非你是a),并且很快就会停止工作。您最好考虑使用类似的工具。

没有用于发布状态的Google+API(除非您是),并且很快将停止工作。您最好考虑使用类似的工具。

没有用于发布状态的Google+API(除非您是),并且很快将停止工作。您最好考虑使用类似的工具。

没有用于发布状态的Google+API(除非您是),并且很快将停止工作。最好的办法是使用。

这样的工具,以便不显示移动的代理,您必须设置代理头,如firefox或其他工具 示例

curl_setopt($curl, CURLOPT_URL, 'https://www.plus.google.com/');
curl_setopt($curl,"USER_AGENT","firefox my browser");
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); //Added here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //Added here
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // Since you got 301 redirect

 $response = curl_exec($curl);
 var_dump($response);// Added here
  curl_close($curl);`enter code here`

为了不显示移动的代理,您必须设置代理头,如firefox或其他 示例

curl_setopt($curl, CURLOPT_URL, 'https://www.plus.google.com/');
curl_setopt($curl,"USER_AGENT","firefox my browser");
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); //Added here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //Added here
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // Since you got 301 redirect

 $response = curl_exec($curl);
 var_dump($response);// Added here
  curl_close($curl);`enter code here`

为了不显示移动的代理,您必须设置代理头,如firefox或其他 示例

curl_setopt($curl, CURLOPT_URL, 'https://www.plus.google.com/');
curl_setopt($curl,"USER_AGENT","firefox my browser");
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); //Added here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //Added here
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // Since you got 301 redirect

 $response = curl_exec($curl);
 var_dump($response);// Added here
  curl_close($curl);`enter code here`

为了不显示移动的代理,您必须设置代理头,如firefox或其他 示例

curl_setopt($curl, CURLOPT_URL, 'https://www.plus.google.com/');
curl_setopt($curl,"USER_AGENT","firefox my browser");
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); //Added here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //Added here
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // Since you got 301 redirect

 $response = curl_exec($curl);
 var_dump($response);// Added here
  curl_close($curl);`enter code here`

我也有输出,但是这样的响应被301移动了文档已经移动了查看编辑的代码,
curl\u setopt($curl,CURLOPT\u FOLLOWLOCATION,true)您需要301状态代码的参数。通过添加一个代码,它将产生如下未授权错误401您可以使用上面的代码进行检查吗?我无法跟踪上面的代码有什么问题非常感谢您的帮助我也有输出,但这样的响应已被301移动文档已移动查看编辑的代码,
curl\u setopt($curl,CURLOPT_FOLLOWLOCATION,true);
您需要301状态代码的参数。添加一个代码将产生如下未授权错误401您可以使用上面的代码进行检查吗?我无法跟踪上面的代码有什么问题非常感谢您的帮助我也有了输出,但这样的响应已被301移动文档已移动查看编辑的代码,
curl\u setopt($curl,CURLOPT_FOLLOWLOCATION,true);
您需要301状态代码的参数。添加一个代码将产生如下未授权错误401您可以使用上面的代码进行检查吗?我无法跟踪上面的代码有什么问题非常感谢您的帮助我也有了输出,但这样的响应已被301移动文档已移动查看编辑的代码,
curl\u setopt($curl,CURLOPT_FOLLOWLOCATION,true);
您需要301状态代码的参数。通过添加一个代码,它将产生如下未授权错误401您可以使用上面的代码进行检查吗?我无法跟踪上面的代码有什么问题谢谢您的帮助