Page 1 of 1

build a URL with variables in it

Posted: Fri May 02, 2008 12:11 am
by lcp
Hi, I would like to include variables into a URL that I am passing to Yahoo Pipes. In the URL below, I would like to have a variable for EndTime (set below to yesterday) and StartDate (set below to 15+days).
http://pipes.yahoo.com/pipes/pipe.run?EndDate=yesterday&StartDate=%2B15+days&_id=84&_render=kml

This URL is being passed in my html code that generates a google map:
var geoXml2 = new GGeoXml(http://pipes.yahoo.com/pipes/pipe.run?EndDate=yesterday&StartDate=%2B15+days&_id=23e0135e18323711db0d9db51ccca684&_render=kml;

If I could assign the EndTime and StartTime to variables, then I could control what comes back from the Yahoo Pipe onto the map. I think php is the right way to do this, but I'm not sure how.
Thanks!

Re: build a URL with variables in it

Posted: Fri May 02, 2008 1:19 am
by Christopher

Code: Select all

echo "var geoXml2 = new GGeoXml('http://pipes.yahoo.com/pipes/pipe.run?EndDate=$enddate&StartDate=$startdate&_id=$id&_render=kml')";

Re: build a URL with variables in it

Posted: Fri May 02, 2008 1:52 am
by Kastor

Code: Select all

 urlencode("http://pipes.yahoo.com/pipes/pipe.run?EndDate={$enddate}&StartDate=$startdate&_id={$id}&_render=kml");

Re: build a URL with variables in it

Posted: Fri May 02, 2008 4:16 am
by youscript
Also can use the function rawurlencode to bulid it

Re: build a URL with variables in it

Posted: Fri May 02, 2008 4:20 pm
by lcp
Hi, thanks for the help. This is how I solved it:
The code below is in the middle of regular html but the file ends in .php. I guess the browser just reads the page as html. This is set up so that when the URL to the .php page has the variables of start, end, etc in the URL that it populated the Yahoo Pipes URL in the php code:
www.example.com/gmaps.php?start=15&end=yesterday&fname=Joe&lname=Blow&zip=11111

Next step is to figure out how to make a web form that fills the variables. Any ideas?

<?
$enddate = $_REQUEST['end'];
$startdate = $_REQUEST['start'];
$fname = $_REQUEST['fname'];
$lname = $_REQUEST['lname'];
$zip = $_REQUEST['zip'];

echo "var geoXml2 = new GGeoXml(\"http://pipes.yahoo.com/pipes/pipe.run?EndDate=$end&Firstname=$fname&Lastname=$lname&StartDate=%2B$start+days&Zip=$zip&_id=84&_render=kml\");";
?>