簡體   English   中英

PHP CURL函數不適用於Google時區api

[英]PHP CURL funcion is not working for google timezone api

PHP curl函數從Google時區api中獲取任何信息。

<?php

$url='https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510&timestamp=1331161200&sensor=false';

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL,  $url);                   
$dta = curl_exec($ch);                  

curl_close($ch);
print_r( $dta);
?>

print_r( $dta); 什么都不打印。

但是當我訪問網址https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510&timestamp=1331161200&sensor=false

它給出結果。

我應該如何從鏈接中檢索內容? 誰能幫我?

沒有錯誤,但是Google說了什么

請檢查卷曲錯誤並解決

<?php
    $url='https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510&timestamp=1331161200&sensor=false';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($ch);
    print_r($data);
    if(curl_errno($ch))  echo 'Curl error: ' . curl_error($ch);  
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM