cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

trouble with multiple KEY/VALUE pairs in URL

From: John Deck <jdeck_at_berkeley.edu>
Date: Mon, 19 Dec 2005 13:11:38 -0800

Hello, i'm new to curl and have scanned the archives to an answer to
my issue but have found nothing that helped. Hopefully, this is a
simple issue....

I'm having trouble getting curl in php to return results from a web
service that takes multiple GET key/value pairs. Things work OK with
only one key value pair but it seems they get split up if more than
one and then the request doesn't work.

The URL i'm trying to get results from is: http://olla.berkeley.edu:
8080/dm/sal?lat=37&lng=-120&layers=srtm30 which should return a few
lines of XML.

The code i'm trying which just returns an empty page is:
<?php
$url="http://olla.berkeley.edu:8080/dm/sal?
lat=37&lng=-120&layers=srtm30";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_exec($ch);
curl_close($ch);
?>

I tried this using the command line curl, like:

curl -v http://olla.berkeley.edu:8080/dm/sal?
lat=37&lng=-120&layers=srtm30

which gives:

[jdeck@chignik berkeleymappertest]$ curl -v http://olla.berkeley.edu:
8080/dm/sal?lat=37&lng=-120&layers=srtm30
[1] 16368
[2] 16369
[jdeck_at_chignik berkeleymappertest]$ * About to connect() to
olla.berkeley.edu port 8080
* Trying 169.229.248.179... * connected
* Connected to olla.berkeley.edu (169.229.248.179) port 8080
> GET /dm/sal?lat=37 HTTP/1.1
User-Agent: curl/7.12.1 (i386-redhat-linux-gnu) libcurl/7.12.1
OpenSSL/0.9.7a zlib/1.2.1.2 libidn/0.5.6
Host: olla.berkeley.edu:8080
Pragma: no-cache
Accept: */*

< HTTP/1.1 500 Internal Server Error
< Server: Apache-Coyote/1.1
< Content-Type: text/html;charset=utf-8
< Content-Length: 1631
< Date: Mon, 19 Dec 2005 21:06:57 GMT
< Connection: close
<html><head><title>Apache Tomcat/5.5.12 - Error report</
title><style><!--H1 {font-family:Tahoma,Arial,sans-
serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-
family:Tahoma,Arial,sans-serif;color:white;background-
color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-
serif;color:white;background-color:#525D76;font-size:14px;} BODY
{font-family:Tahoma,Arial,sans-serif;color:black;background-
color:white;} B {font-family:Tahoma,Arial,sans-
serif;color:white;background-color:#525D76;} P {font-
family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:
12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--
></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1"
noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</
b> <u></u></p><p><b>description</b> <u>The server encountered an
internal error () that prevented it from fulfilling this request.</
u></p><p><b>exception</b> <pre>java.lang.NullPointerException
         java.util.regex.Matcher.getTextLength(Unknown Source)
         java.util.regex.Matcher.reset(Unknown Source)
         java.util.regex.Matcher.&lt;init&gt;(Unknown Source)
         java.util.regex.Pattern.matcher(Unknown Source)
         java.util.regex.Pattern.split(Unknown Source)
         java.util.regex.Pattern.split(Unknown Source)
         dmSAL.doGet(dmSAL.java:24)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
* Closing connection #0
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is
available in the Apache Tomcat/5.5.12 logs.</u></p><HR size="1"
noshade="noshade"><h3>Apache Tomcat/5.5.12</h3></body></html>

Interestingly, if i enclose the URL in quotes, things work as expected:

curl "http://olla.berkeley.edu:8080/dm/sal?
lat=37&lng=-120&layers=srtm30"

<?xml version="1.0" encoding="UTF-8"?>
<layers>
<srtm30 value = "95.0"/>
</layers>

I'd like to get this to work via PHP and tried putting extra quotes
in the URL string in PHP but that didn't work... Any clues??

thanks!
John Deck
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2005-12-19