curlを使ってアナログ登録を行います.
8820 ワード
$cookie_path = './'; // cookie
//----- ---------------
$vars['username'] = ' ';
$vars['pwd'] = '123';
//-------------------------------------
$method_post = true;
// url ( action )
$url = 'http://****.com/login';
//----------------------------
$ch = curl_init();
$params[CURLOPT_URL] = $url; // url
$params[CURLOPT_HEADER] = true; //
$params[CURLOPT_RETURNTRANSFER] = true; //
$params[CURLOPT_FOLLOWLOCATION] = true; //
$params[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1';
$postfields = '';
foreach ($vars as $key => $value){
$postfields .= urlencode($key) . '=' . urlencode($value) . '&';
}
$params[CURLOPT_POST] = true;
$params[CURLOPT_POSTFIELDS] = $postfields;
// cookie,
if (isset($_COOKIE['cookie_jar']) && ($_COOKIE['cookie_jar'] || is_file($_COOKIE['cookie_jar'])))
{
$params[CURLOPT_COOKIEFILE] = $_COOKIE['cookie_jar']; // cookie
}
else
{
$cookie_jar = tempnam($cookie_path, 'cookie'); // cookie
$params[CURLOPT_COOKIEJAR] = $cookie_jar; // cookie
setcookie('cookie_jar', $cookie_jar); // cookie
}
curl_setopt_array($ch, $params); // curl
$content = curl_exec($ch); //
echo '
';
echo $content; //
/*
//--------- , ---------
echo '
';
$nexturl = 'http://****.com/test';
$params[CURLOPT_URL] = $nexturl;
$params[CURLOPT_POSTFIELDS] = '';
curl_setopt_array($ch, $params); // curl
$content = curl_exec($ch); //
echo $content; //
//-------------------------------------------------
*/
curl_close($ch); //
?>