corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » Php Guru's


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author Php Guru's
Dom
Member

Registered: 13th Sep 03
User status: Offline
11th May 09 at 10:01   View User's Profile U2U Member Reply With Quote

Anyone know whether this looks about right?

It should request a variable via 'p' (eg: UKXX1822), grab the XML page (eg: http://weather.yahooapis.com/forecastrss?p=UKXX1822&u=c) and then spit it back out (with the content type set to text/xml). So when requesting the page, it should be exactly the same as if you requested it from yahoo.


code:

<?php
$place = $_REQUEST["p"];

If ($place != "") {
$content = file_get_contents('http://weather.yahooapis.com/forecastrss?p='.$place.'&u=c');
if ($content !== false) {
header('Content-Type: text/xml');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . strlen($content))
print($content);
}
}
?>



Cheers

edit -

these are the headers returned from the yahoo servers -

HTTP/1.x 200 OK
Date: Mon, 11 May 2009 09:50:35 GMT
Cache-Control: max-age=1200
Expires: Mon, 11 May 2009 10:10:35 GMT
Vary: Accept-Encoding
Content-Type: text/xml;charset=UTF-8
Content-Encoding: gzip
X-Pad: avoid browser bug
Age: 0
Transfer-Encoding: chunked
Connection: keep-alive
Server: YTS/1.17.16

[Edited on 11-05-2009 by Dom]
Sam
Moderator
Premium Member


Registered: 24th Dec 99
Location: West Midlands
User status: Offline
11th May 09 at 12:29   View User's Profile U2U Member Reply With Quote

Try changing this:

code:
If ($place != "") {


to this:

code:
If ($place) {


Does it work then?

[Edited on 11-05-2009 by Sam]
Ian
Site Administrator

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Online
13th May 09 at 16:44   View Garage View User's Profile U2U Member Reply With Quote

I would be checking $place is set first - echo it.
Dom
Member

Registered: 13th Sep 03
User status: Offline
13th May 09 at 18:11   View User's Profile U2U Member Reply With Quote

cheers for the help, have managed to sort it
ed
Member

Registered: 10th Sep 03
User status: Offline
13th May 09 at 19:11   View User's Profile U2U Member Reply With Quote

quote:
Originally posted by Ian
I would be checking $place is set first - echo it.
Wouldn't you use isset() to do that?
Ian
Site Administrator

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Online
13th May 09 at 19:35   View Garage View User's Profile U2U Member Reply With Quote

If you trust isset(), yes
Laney
Member

Registered: 6th May 03
Location: Leeds
User status: Offline
13th May 09 at 21:53   View User's Profile U2U Member Reply With Quote

!empty() is probably a safer bet.
Sam
Moderator
Premium Member


Registered: 24th Dec 99
Location: West Midlands
User status: Offline
14th May 09 at 08:24   View User's Profile U2U Member Reply With Quote

Or a combination of both...
Ian
Site Administrator

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Online
14th May 09 at 20:56   View Garage View User's Profile U2U Member Reply With Quote

I echo on live code, I'm hardcore.
ed
Member

Registered: 10th Sep 03
User status: Offline
14th May 09 at 23:05   View User's Profile U2U Member Reply With Quote

But if you echo'd wouldn't it throw an error when you're setting the headers?
Ian
Site Administrator

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Online
15th May 09 at 21:15   View Garage View User's Profile U2U Member Reply With Quote

Yeah comment that while you're developing.

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
Porn Star Guru (18+) Jamie General Chat 4 286
11th Jun 03 at 12:47
by jay@ffwd
 
Car lower on one side than the other............ Nath Help Zone, Modification and ICE Advice 37 6324
10th Sep 03 at 15:56
by The Guru
 
CORSA vs FOCUS kz General Chat 139 4049
11th Oct 03 at 22:03
by Kris TD
 
Urgently need a 1.0 12V -Aliba- Scotland 6 444
14th Apr 04 at 21:30
by -Aliba-
 
Ryan.... Skipz Scotland 33 1311
1st Jun 05 at 23:35
by vibrio
 

Corsa Sport » Message Board » Off Day » Geek Day » Php Guru's 29 database queries in 0.0137460 seconds