Thank you for answering my question.
When I apply the code below:
$sparql_query=" SELECT ?label WHERE { ?label ?a ?b} ";
$c = curl_init();
$headers = array("Accept: application/sparql-results+html");
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_URL, "http://dbpedia.org/sparql");
curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, "query=".urlencode($sparql_query));
$result = curl_exec($c);
echo curl_error($c);
curl_close($c);
echo $result;
I get the results as expected.
However, when I change sparql_query line with below:
$sparql_query="SELECT ?label WHERE { { ?a <
http://dbpedia.org/resource/Turkey> <http://dbpedia.org/resource/Capital> .
} UNION { <http://dbpedia.org/resource/Turkey> ?a <
http://dbpedia.org/resource/Capital> . } UNION { <
http://dbpedia.org/resource/Turkey> <http://dbpedia.org/resource/Capital> ?a
. } UNION { ?a <http://dbpedia.org/resource/Turkey> <
http://dbpedia.org/property/capital> . } UNION { <
http://dbpedia.org/resource/Turkey> ?a <http://dbpedia.org/property/capital>
. } UNION { <http://dbpedia.org/resource/Turkey> <
http://dbpedia.org/property/capital> ?a . } UNION { ?a <
http://dbpedia.org/property/turkey> <http://dbpedia.org/resource/Capital> .
} UNION { <http://dbpedia.org/property/turkey> ?a <
http://dbpedia.org/resource/Capital> . } UNION { <
http://dbpedia.org/property/turkey> <http://dbpedia.org/resource/Capital> ?a
. } UNION { ?a <http://dbpedia.org/property/turkey> <
http://dbpedia.org/property/capital> . } UNION { <
http://dbpedia.org/property/turkey> ?a <http://dbpedia.org/property/capital>
. } UNION { <http://dbpedia.org/property/turkey> <
http://dbpedia.org/property/capital> ?a . } UNION { ?a <
http://dbpedia.org/resource/Capital> <http://dbpedia.org/resource/Turkey> .
} UNION { <http://dbpedia.org/resource/Capital> ?a <
http://dbpedia.org/resource/Turkey> . } UNION { <
http://dbpedia.org/resource/Capital> <http://dbpedia.org/resource/Turkey> ?a
. } UNION { ?a <http://dbpedia.org/resource/Capital> <
http://dbpedia.org/property/turkey> . } UNION { <
http://dbpedia.org/resource/Capital> ?a <http://dbpedia.org/property/turkey>
. } UNION { <http://dbpedia.org/resource/Capital> <
http://dbpedia.org/property/turkey> ?a . } UNION { ?a <
http://dbpedia.org/property/capital> <http://dbpedia.org/resource/Turkey> .
} UNION { <http://dbpedia.org/property/capital> ?a <
http://dbpedia.org/resource/Turkey> . } UNION { <
http://dbpedia.org/property/capital> <http://dbpedia.org/resource/Turkey> ?a
. } UNION { ?a <http://dbpedia.org/property/capital> <
http://dbpedia.org/property/turkey> . } UNION { <
http://dbpedia.org/property/capital> ?a <http://dbpedia.org/property/turkey>
. } UNION { <http://dbpedia.org/property/capital> <
http://dbpedia.org/property/turkey> ?a . } . ?a rdfs:label ?label . FILTER
(LANG(?label) = 'en')}";
I get:
*ERROR
The requested URL could not be retrieved
While trying to process the request:
POST /sparql HTTP/1.1
Host: dbpedia.org
Accept: application/sparql-results+html
Content-Length: 3129
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue
The following error was encountered:
* Invalid Request
Some aspect of the HTTP Request is invalid. Possible problems:
* Missing or unknown request method
* Missing URL
* Missing HTTP Identifier (HTTP/1.0)
* Request is too large
* Content-Length missing for POST or PUT requests
* Illegal character in hostname; underscores are not allowed
Your cache administrator is [email protected].
*
Where am i doing wrong?
Thanks in advance again.
Ahmet
On Tue, Mar 31, 2009 at 5:28 PM, Jens Lehmann <
[email protected]> wrote:
>
> Hello,
>
> Jens Lehmann schrieb:
> > Hello,
> >
> > $headers = array("Content-Type: ".$this->contentType);
> > $c = curl_init();
> > curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
> > curl_setopt($c, CURLOPT_URL, $url);
> > curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
> > $contents = curl_exec($c);
> > curl_close($c);
>
> Here is the corresponding POST code:
>
> $c = curl_init();
> $headers = array("Accept: application/sparql-results+JSON");
> curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
> curl_setopt($c, CURLOPT_URL, "http://dbpedia.org/sparql");
> curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
> curl_setopt($c, CURLOPT_POST, true);
> curl_setopt($c, CURLOPT_POSTFIELDS, "query=$query");
> $contents = curl_exec($c);
> echo curl_error($c);
> curl_close($c);
>
> Kind regards,
>
> Jens
>
>
>
------------------------------------------------------------------------------
> _______________________________________________
> Dbpedia-discussion mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion
>
------------------------------------------------------------------------------
_______________________________________________
Dbpedia-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion