[OSM-talk] Re: Re: [OSM-dev] PHP code

Erik Johansson erjohan at gmail.com
Sat Jul 29 15:03:12 BST 2006


On 7/29/06, Nick Whitelegg <nick at hogweed.org> wrote:
> On Saturday 29 Jul 2006 12:14, OJW wrote:
> > Does anyone have a snippet of PHP code for adding a node to openstreetmap?
> > I'm having trouble figuring out how to do the PUT request in a way that the
> > API understands...
> >
> > _______________________________________________
> > dev mailing list
> > dev at openstreetmap.org
> > http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/dev
>
> Using cURL, this will take some OSM XML ($osm) and send it to API call
> $osmapicall. $ver is the OSM version.
> From what I remember, with cURL you couldn't just stream data across without
> saving it to a temporary file first.
>
> Nick
>
> --
>


function uploadToOSM($osmapicall,$osm,$ver)
{
    $resp=0;
    $t=time();
    $url = "http://www.openstreetmap.org/api/$ver/$osmapicall";

    $ch=curl_init ($url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch,CURLOPT_HEADER,false);
    curl_setopt($ch,CURLOPT_USERPWD,OSM_LOGIN);
    curl_setopt($ch,CURLOPT_PUT,true);
    curl_setopt($ch,CURLOPT_POSTFIELDS,$osm);
...^^^^


I think this might work instead, I don't know about PHP but that was
what I used in C.




More information about the talk mailing list