Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Calling API via URL by substituting server variable?

Posted on 2005-03-06
5
Medium Priority
?
218 Views
Last Modified: 2013-11-18
Hi,


I know one API which can crab information about IP i.e. location, city etc.

http://www.hostip.info/api/get.html?ip=12.215.42.19

I want above ip replaced with Request.ServerVariables("REMOTE_HOST"). So that when someone visit a webpage, it get ip address and then populate it in URL.

So I am looking something:

http://www.hostip.info/api/get.html?ip=Request.ServerVariables("REMOTE_HOST") to be called as Server Side Include.

Thanks for your help.

Nick  
0
Comment
Question by:NickHoward
5 Comments
 
LVL 8

Expert Comment

by:fatalXception
ID: 13472212
using ASP?
First line of your page will be
<%
dim ipAddr
ipAddr = request.ServerVariables("REMOTE_HOST")
%>
then
<script language = "javascript">
function go()
{
   document.location = 'http://www.hostip.info/api/get.html?ip=<%=ipAddr%>';
}
</script>
<body onload = 'go()'>
etc

should work for you.
0
 

Author Comment

by:NickHoward
ID: 13472488
Thanks fatal.

But how to control it by displaying in specific location of page?

Nick
0
 

Author Comment

by:NickHoward
ID: 13472568
Furthermore your provided code redirect the page to http://www.hostip.info while I want that all information fetched remain in my asp page.

Please advice.

Nick
0
 
LVL 13

Accepted Solution

by:
StormyWaters earned 375 total points
ID: 13472991
Are you going to be manipulating that data in any way? If not, just put it in an IFRAME:

<iframe id="hostip" src="http://www.hostip.info/api/get.html?ip=<%=request.ServerVariables("REMOTE_HOST")>">Wow, you have a really old browser. Time to upgrade!</iframe>

Style as you want (in the <head>):

<style type="text/css">
#hostip {
  border:0px;
  width:100px;
  height:5em;
}
/* ...etc...*/
<style>
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 13473860
FYI: http://www.hostip.info/ reports my IP locations as follows

Merritt Island, FL, UNITED STATES
Kennewick, WA, UNITED STATES
Brooks, ME, UNITED STATES
Lewisville, TX, UNITED STATES
Sun City, AZ, UNITED STATES

None of which are even close.

The definative source for the Americas is ARIN which correctly reports the owner and location of my IP block.

http://ws.arin.net/cgi-bin/whois.pl?queryinput=64.151.6.52&b1=Submit

http://www.arin.net/tools/whois_help.html


0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question