2011-06-22 188 views
0

年齡偏大的問題。需要找到解決方案。jQuery獲取IP地址

此:

$ .getJSON( 「?http://jsonip.appspot.com?callback=」,功能(數據){IP = data.ip});

似乎不工作了:

App Engine Error 

Over Quota 

This Google App Engine application is temporarily over its serving quota. 
Please try again later. 

我發現這個http://checkip.dyndns.org/

我用負載(數據類型設置爲JSONP)來嘗試獲得HTML,但我不認爲我這樣做正確或不能完成。

任何幫助?

感謝堆棧;-)

+0

不知道你在問什麼。使用第一個應用程序時遇到的錯誤與您的代碼無關:http://code.google.com/appengine/kb/general.html#quota –

+3

如何編寫您自己的簡單服務器端「IP檢查器應用程序「而不是使用第三方?這裏有一個在PHP中:'<?php echo $ _SERVER ['REMOTE_ADDR']; ?>':) – deceze

回答

5

只需創建與下面的代碼的PHP文件:

回聲 '[{ 「IP」: 「$ _ SERVER [ 'REMOTE_ADDR']」}]' ;

,然後平與得到JSON

+0

是的,這就是我認爲+1 – Pablo

+0

謝謝你的迴應。只有HTML可供我處理。 – Barry

2
<!-- Require jQuery/Anyversion --><script type="text/javascript" language="Javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> 
<!-- Require EasyJQuery After JQuery --><script type="text/javascript" language="Javascript" src="http://api.easyjquery.com/easyjquery.js"></script> 
<script type="text/javascript" language="Javascript"> 
    // 1. Your Data Here 
    function my_callback(json) { 
     alert("IP :" + json.IP + " \nCountry: " + json.Country); 
    } 

    function my_callback2(json) { 
     // more information at http://api.easyjquery.com/test/demo-ip.php 
     alert("IP :" + json.IP + " \nCountry: " + json.Country + " City: " + json.CityName + " RegionName: " + json.RegionName); 
    } 

    // 2. Setup Callback Function 
    // EasyjQuery_Get_IP("my_callback"); // fastest version 
    EasyjQuery_Get_IP("my_callback2","full"); // full version 
</script> 



[IP] => 93.154.204.205 
    [ContinentCode] => NA 
    [ContinentName] => North America 
    [CountryCode2] => US 
    [CountryCode3] => USA 
    [COUNTRY] => US 
    [CountryName] => United States 
    [RegionName] => California 
    [CityName] => Garden Grove 
    [CityLatitude] => 33.7831 
    [CityLongitude] => -118.0271 
    [CountryLatitude] => 38 
    [CountryLongitude] => -98 
    [LocalTimeZone] => America/Los_Angeles 
    [REMOTE_ADDR] => 77.93.210.64 
    [HTTP_X_FORWARDED_FOR] => 
    [CallingCode] => 1 
    [Population] => 307,212,123 (3) 
    [AreaSqKm] => 9,826,675 (4) 
    [GDP_USD] => 14.26 Trillion (1) 
    [Capital] => Washington, D.C. 
    [Electrical] => 120 V,60 Hz Type A Type B 
    [Languages] => English 82.1%, Spanish 10.7%, other Indo-European 3.8%, Asian and Pacific island 2.7%, other 0.7% (2000 census) 
    [Currency] => US Dollar (USD) 
    [Flag] => http://api.easyjquery.com/proips/flags/US.jpg 
+0

請包括你的代碼與你的答案一起做的解釋。 –