ใช้ cURL สำหรับ login หน้าเว็บที่ต้อง login ก่อน

Using cURL to get login to yahoo.com by Porosh

http://www.weberdev.com/get_example.php3?ExampleID=4277

<?php 
// Script created by Nur-E-Alam Khan 
// Email: porosh@msn.com (Dhaka, Bangladesh) 

$url ="http://login.yahoo.com/config/login?.src=ym&.intl=us&.partner=&.done=http%3A%2F%2Fmail.yahoo.com%2F"; 
$ch = curl_init();      
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); 
curl_setopt ($ch, CURLOPT_COOKIEJAR, '/temp/cookie.txt'); 
curl_setopt ($ch, CURLOPT_POSTFIELDS, "login=emailid&passwd=password&&submit=Sign In"); 
ob_start();      
curl_exec ($ch); 
ob_end_clean();  
curl_close ($ch); 
unset($ch); 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch, CURLOPT_COOKIEFILE, "/temp/cookie.txt"); 
curl_setopt($ch, CURLOPT_URL,"http://us.f515.mail.yahoo.com/ym/login?"); 
$result = curl_exec ($ch); 

curl_close ($ch); 
echo $result; 
?>

* * * * *

[Keywords]

php file_get_contents sign in login

Advertisements