Advertisement
Guest User

Untitled

a guest
Jul 1st, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. function ddcurl_login($url, $username, $password) {
  2.   $ch = curl_init();
  3.  
  4.   $post_data = array(
  5.     'username' => $username,
  6.     'password' => $password
  7.   );
  8.   //$post_data = "username=$username&password=$password";
  9.  
  10.   curl_setopt($ch, CURLOPT_URL, $url);
  11.   curl_setopt($ch, CURLOPT_FAILONERROR, 1);
  12.   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  13.   curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
  14.   curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
  15.   curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)');
  16.   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  17.   curl_setopt($ch, CURLOPT_POST, 1);
  18.   curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  19.   $data = curl_exec ($ch);
  20.  
  21.   curl_close ($ch);
  22.   return $data;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement