SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict khuramyz's Avatar
    Join Date
    Oct 2005
    Location
    Manchester, UK
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php problem with maps api

    Hello there
    I have just joined this group and this my first email. I hope you people help me out.

    You see i am making a web application where I have a street address which i am sending to the yahoo maps and it returns me with the XML Stream of the location containing Longtitude and Lattitude of the location. I put the yahoo api web service url in the browser address bar and it showed me the stream correctly.

    here's the URL
    http://api.local.yahoo.com/MapsServi...lotte&state=NC

    and here's the return.

    <?xml version="1.0" ?>
    - <ResultSet xmlnssi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:yahoo:maps" xsi:schemaLocation="urn:yahoo:maps http://api.local.yahoo.com/MapsService/V1/GeocodeResponse.xsd">
    - <Result precision="address">
    <Latitude>35.213705</Latitude>
    <Longitude>-80.844309</Longitude>
    <Address>911 E MOREHEAD ST</Address>
    <City>CHARLOTTE</City>
    <State>NC</State>
    <Zip>28204-2856</Zip>
    <Country>US</Country>
    </Result>
    </ResultSet>
    - <!-- ws02.search.re2.yahoo.com compressed/chunked Wed Jun 14 01:11:28 PDT 2006
    -->

    The problem is that when I try to give this URL in the file() function of the php, it does not assign it the resource ID.
    Here's the php code.

    if(!($stream = file("$url",'r'))) {
    die("could not open file.");
    }

    Can you people help me out what's the problem. I would be very thankful if someone brought me the solution to this.
    Thanks.

    Khuram Javaid
    Software Engineer
    NextBridge, Pakistan

  2. #2
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use [code] tags when you post something with code in it.
    This post should have been posted in the PHP forum, which deals with practical issues.

    Is the contents of $url correct ? (Have you tried echo'ing in the line before the fopen() call?)
    If yes, your problem is most likely that the curl stream wrappers aren't activated. If you're on a shared host, then tough luck - otherwise, you should be able to activate it (I don't remember if you can just change a php.ini setting, or if you actually need to recompile php) - The manual probably have this information.

  3. #3
    SitePoint Addict khuramyz's Avatar
    Join Date
    Oct 2005
    Location
    Manchester, UK
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there
    I have checked the value of URL and its filled with right value. Dont know about the Curl though. I'll check. Should I post it somewhere else ??

  4. #4
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this thread is too old but I was searching for something and found it.

    please use below code and it would work fine

    Code:
    $url = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=cityRewardsMap&street=911+East+Morehead+Street&city=Charlotte&state=NC";
    if(!($stream = file($url))) {
    die("could not open file.");
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •