curl

 

 

$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 ;

 

posted @ 2015-07-16 17:48  坠落鱼  阅读(180)  评论(0编辑  收藏  举报