flypighuang

1.用file_get_contents()函数

$params = array(\'key\' => \'8d284859d04cfeeea6b0771f754adb49\',
    \'location\' => $_COOKIE["lng"].",".$_COOKIE["lat"]);

$url3 = "http://restapi.amap.com/v3/geocode/regeo";

if (strripos(\'?\', $url3)) {
  $url4 = $url3 . http_build_query($params);
} else {
  $url4 = $url3 . \'?\' . http_build_query($params);
}

$ret2 = json_decode(file_get_contents($url4));

var_dump($ret);

 

2.用php的curl拓展

 $url2 = \'http://www.sojson.com/open/api/weather/json.shtml\';
  
 $params = array(\'city\' => \'长沙\');
 
 if (strripos(\'?\', $url2)) {
    $url = $url2 . http_build_query($params);
 } else {
    $url = $url2 . \'?\' . http_build_query($params);
 }
 
$data = \'city=长沙\';
$curlobj = curl_init();    
curl_setopt($curlobj, CURLOPT_URL, $url);  
curl_setopt($curlobj, CURLOPT_HEADER, 0); 
curl_exec($curlobj);

 

分类:

技术点:

相关文章:

  • 2021-06-23
  • 2021-12-15
  • 2022-01-08
  • 2021-06-14
  • 2022-12-23
  • 2021-12-05
  • 2021-08-11
  • 2021-09-28
猜你喜欢
  • 2021-11-28
  • 2022-02-07
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
  • 2022-01-31
  • 2022-12-23
相关资源
相似解决方案