日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
phpcurl怎么只獲取數(shù)據(jù)

本文操作環(huán)境:windows7系統(tǒng)、php7.1版、DELL G3電腦

創(chuàng)新互聯(lián)專注于軹城企業(yè)網(wǎng)站建設(shè),成都響應(yīng)式網(wǎng)站建設(shè)公司,商城網(wǎng)站開發(fā)。軹城網(wǎng)站建設(shè)公司,為軹城等地區(qū)提供建站服務(wù)。全流程定制網(wǎng)站制作,專業(yè)設(shè)計,全程項目跟蹤,創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)

php curl 怎么只獲取數(shù)據(jù)?

php 使用 CURL 獲取數(shù)據(jù)

第一種,POST 和 GET 合并

function http_curl($url, $type = 'get', $data = ''){
  $cl = curl_init();  //初始化
  curl_setopt($cl, CURLOPT_URL, $url);  //設(shè)置 cURL 傳輸選項
  curl_setopt($cl, CURLOPT_RETURNTRANSFER, 1);  // 將curl_exec()獲取的信息以字符串返回,而不是直接輸出。
  curl_setopt($cl, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($cl, CURLOPT_SSL_VERIFYHOST, false);
  if($type == 'post'){
    curl_setopt($cl, CURLOPT_POST, 1);    //發(fā)送 POST 請求,類型為:application/x-www-form-urlencoded
    curl_setopt($cl, CURLOPT_POSTFIELDS, $data);
  }
  $output = curl_exec($cl);  //執(zhí)行 cURL 會話
  curl_close($cl);
  return $output;
}

第二種 POST 和 GET分開

POST

$url = "http://localhost/web_services.php";
  $post_data = array ("username" => "bob","key" => "12345");  
   $ch = curl_init(); 
   curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  // post數(shù)據(jù)
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  // post的變量
  curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); 
   $output = curl_exec($ch);
  curl_close($ch); 
   //打印獲得的數(shù)據(jù)
  print_r($output);

GET

  //初始化
  $ch = curl_init();  
   //設(shè)置選項,包括URL
  curl_setopt($ch, CURLOPT_URL, "http://www.jb51.net");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_HEADER, 0); 
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
   //執(zhí)行并獲取HTML文檔內(nèi)容
  $output = curl_exec($ch); 
   //釋放curl句柄
  curl_close($ch); 
   //打印獲得的數(shù)據(jù)
  print_r($output);

以上方式獲取到的數(shù)據(jù)是json格式的

使用 json_decode($output,true)可解析為數(shù)組;使用 json_decode($output) 可解析為對象

參數(shù)說明:


新聞名稱:phpcurl怎么只獲取數(shù)據(jù)
本文鏈接:http://www.5511xx.com/article/cdsdsjo.html