Welcome Guest, Not a member yet? Register   Sign In
xmlrpc weather
#1

[eluser]jdfwarrior[/eluser]
I'm playin around with the XMLRPC library and was trying to pull Weather from weather.com's site through thier api. With the provided url they provide to pull the xml, I get what looks like a valid response, but the xmlrpc class obviously things other wise.

Code:
---DATA---
HTTP/1.1 200 OK
Date: Sun, 08 Mar 2009 18:50:42 GMT
Server: Apache
Cache-Control: max-age=300
Content-Length: 1430
Keep-Alive: timeout=1, max=7441
Connection: Keep-Alive
Content-Type: application/xml;charset=ISO-8859-1

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- This document is intended only for use by authorized licensees of The  -->
<!-- Weather Channel. Unauthorized use is prohibited.  Copyright 1995-2009, -->
<!-- The Weather Channel Interactive, Inc.  All Rights Reserved.            -->
<weather ver="2.0">
  &lt;head&gt;
    <locale>en_US</locale>
    &lt;form&gt;MEDIUM&lt;/form&gt;
    <ut>F</ut>
    <ud>mi</ud>
    <us>mph</us>
    <up>in</up>
    <ur>in</ur>
  &lt;/head&gt;
  <loc id="38930">
    <dnam>Greenwood, MS (38930)</dnam>
    <tm>1:50 PM</tm>
    <lat>33.52</lat>
    <lon>-90.18</lon>
    <sunr>6:20 AM</sunr>
    <suns>7:03 PM</suns>
    <zone>-5</zone>
  </loc>
  <swa>
    <a id="494408" uc="0">
      <t>WIND ADVISORY UNTIL SUN MAR 08 2009 06:30 PM CDT</t>
      <l>http://www.weather.com/weather/newscenter/alerts?alertId=494408</l>
    </a>
  </swa>
  <cc>
    <lsup>3/8/09 12:53 PM CDT</lsup>
    <obst>Greenwood, MS</obst>
    <tmp>77</tmp>
    <flik>78</flik>
    <t>Mostly Cloudy</t>
    <icon>28</icon>
    <bar>
      <r>30.05</r>
      <d>falling</d>
    </bar>
    <wind>
      <s>21</s>
      <gust>28</gust>
      <d>200</d>
      <t>SSW</t>
    </wind>
    <hmid>58</hmid>
    <vis>10.0</vis>
    <uv>
      <i>4</i>
      <t>Moderate</t>
    </uv>
    <dewp>61</dewp>
    <moon>
      <icon>12</icon>
      <t>Waxing Gibbous</t>
    </moon>
  </cc>
</weather>


---END DATA---


---Invalid Return--- Top level XML-RPC element is missing---Invalid Return---

I keep getting this error every time.

Code:
$this->xmlrpc->set_Debug(TRUE);
$this->xmlrpc->server('http://xoap.weather.com/weather/local/38930?cc=*&par=1104178194&key=keyhere');
$result = $this->xmlrpc->send_request();
if ($result) { $weather = "success"; }
else { $weather = $this->xmlrpc->display_error(); }

This all the code I'm using at this point, just trying to get a successful return. Anyone see anything I'm doing wrong or have any experience with this that could point me in the right direction?
#2

[eluser]TheFuzzy0ne[/eluser]
What's the error message you're getting?
#3

[eluser]jdfwarrior[/eluser]
The XML data received was either invalid or not in the correct form for XML-RPC. Turn on debugging to examine the XML data further. Top level XML-RPC element is missing.
#4

[eluser]pistolPete[/eluser]
Your XML is not a valid XML-RPC response.
There must be either a <methodCall> or a <methodResponse> element: http://www.xmlrpc.com/spec

You are not using XML-RPC, you only get an XML formatted response which you need to parse accordingly.

Btw: You should remove the API key from above...
#5

[eluser]TheFuzzy0ne[/eluser]
Nuts. I thought I'd be able to help by looking at the source code, but I keep getting lost... Sorry.
#6

[eluser]CroNiX[/eluser]
You might also be able to tell a little by looking at the response you get back, not just if there is an error.
Code:
$response = $this->xmlrpc->display_response();
print_r($response);
#7

[eluser]jdfwarrior[/eluser]
Thats what this is..

"The XML data received was either invalid or not in the correct form for XML-RPC. Turn on debugging to examine the XML data further. Top level XML-RPC element is missing. "

Anyone know of an easy way to parse this out? Been beating my head against the wall for a while now messin with it
#8

[eluser]CroNiX[/eluser]
No, you are viewing only the error, not the direct response in its entirety.
#9

[eluser]jdfwarrior[/eluser]
Yeah good call, but response doesnt return anything
#10

[eluser]mitchwilson[/eluser]
I'm having a problem with this too. The response printed to my browser is Array.




Theme © iAndrew 2016 - Forum software by © MyBB