?
Solved

Calling API via URL by substituting server variable?

Posted on 2005-03-06
5
Medium Priority
?
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

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

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses

777 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