首页 > Web开发 > 详细

curl

时间:2015-07-16 19:16:18      阅读:356      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!