Utilisateur:Amgine/basebot.php/login

Une nouvelle de Wikinews, la source d'informations que vous pouvez écrire.
/**
 * login method
 **/
function login( $mwUser, $mwPass, $mwSite ){
	$ch = curl_init( $mwSite );
	$postvars = array(
		'action' 		=> 'login',
		'lgname' 		=> $mwUser,
		'lgpassword'		=> $mwPass,
	);
		
	curl_setopt( $ch, CURLOPT_POST, true );
	curl_setopt( $ch, CURLOPT_POSTFIELDS, $postvars );
	curl_setopt( $ch, CURLOPT_COOKIESESSION, true );
	curl_setopt( $ch, CURLOPT_COOKIEJAR, 'cookies.txt' );

	return curl_exec( $ch );
}