Цитата |
$eq = 'accountType=HOSTED_OR_GOOGLE&Email=email&Passwd=pass&service=youtube&source=test 1'; if ($fp = fsockopen ("ssl://www.google.com", 443, $errno, $errstr, 20)) { $request ="POST /youtube/accounts/ClientLogin HTTP/1.0\r\n"; $request.="Host: www.google.com\r\n"; $request.="Content-Type:application/x-www-form-urlencoded\r\n"; $request.="Content-Length: ".strlen($eq)."\r\n"; $request.="\r\n\r\n"; $request.=$eq; fwrite($fp,$request,strlen($request)); while (!feof($fp)) $response.=fread($fp,8192); fclose($fp); } preg_match("!(.*?)Auth=(.*?)\n!si",$response,$ok); $AUTH_TOKEN = $ok[2]; echo $AUTH_TOKEN; |
<?
$postvars = array(
"Email" => "__________",
"Passwd" => "__________",
"service" => "__________"
);
$postdata = "";
foreach ( $postvars as $key => $value )
$postdata .= "&".rawurlencode($key)."=".rawurlencode($value);
$postdata = substr( $postdata, 1 );
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, "https://www.google.com/accounts/ClientLogin");
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($ch);
preg_match("!(.*?)Auth=(.*?)\n!si",$result,$ok);
echo $ok[2];
/////////////////////
curl_close($ch);
echo "<br><br>";
//echo $result;
?>