码迷,mamicode.com
首页 > Web开发 > 详细

curl

时间:2015-07-16 19:19:02      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:

 

 

$aPostvars = (array) array() ;
$aPostvars[‘action‘] = ‘login‘ ;
$aPostvars[‘username‘] = $this->sUser ;
$aPostvars[‘password‘] = $this->sPass ;

$ch = curl_init(); 
curl_setopt( $ch, CURLOPT_URL, $this->sUrlauth ) ;
curl_setopt( $ch, CURLOPT_HEADER, 0 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ) ;
//curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 ) ;
curl_setopt( $ch, CURLOPT_POST, 1 ) ;
curl_setopt( $ch, CURLOPT_POSTFIELDS, $aPostvars ) ;
//curl_setopt( $ch, CURLOPT_FAILONERROR, true );
curl_setopt( $ch, CURLOPT_USERAGENT, $_SERVER[‘HTTP_USER_AGENT‘]);
curl_setopt( $ch, CURLOPT_PORT, ‘80‘);
  $oReturn = curl_exec($ch) ;    

  if($oReturn === false)
  {
      echo ‘Curl error: ‘ . curl_error($ch) . ‘<br />Curl error code ‘ . curl_errno($ch);
  }

curl_close($ch);
return $oReturn ;

 

curl

标签:

原文地址:http://www.cnblogs.com/zhuiluoyu/p/4652038.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!