在socrata查询opendata 403错误

时间:2016-11-16 15:13:38

标签: json curl http-status-code-403 socrata

我正在查询来自socrata的opendata源的数据。

目标是通过输入牌照来检索车辆的一些信息。代码工作得很好,但几天前停止工作。

//strip licenseplate, it may only contain A-Z and 0-9. 6 chars long: 1XXX11
$kent = strtoupper(preg_replace("/[^a-zA-Z0-9]+/", "", $_GET['kent']));
//start curl
$curl = curl_init();
$timeout = 30;
$ret = '';
$url='https://opendata.rdw.nl/resource/m9d7-ebf2.json?kenteken='.$kent;

curl_setopt ($curl, CURLOPT_URL, $url);
curl_setopt ($curl, CURLOPT_HEADER, true);
curl_setopt ($curl, CURLOPT_HTTPHEADER, 'X-App-Token:MYTOKENHERE');
curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($curl, CURLOPT_MAXREDIRS, 20);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5');
curl_setopt ($curl, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_VERBOSE, true);
//logging
$verbose = fopen('php://temp', 'w+');
curl_setopt($curl, CURLOPT_STDERR, $verbose);

$gegevens = curl_exec($curl);

// Close the handle
curl_close($curl);

rewind($verbose);
$verboseLog = stream_get_contents($verbose);
//print logging
echo "Verbose information:\n<pre>", htmlspecialchars($verboseLog), "</pre>\n";
//de data
$text = json_decode($gegevens,true);
$merk=$text[0]['merk'];
$type=$text[0]['handelsbenaming'];
echo "Brand:".$merk." ".$type;

运行此文件会让我:

Verbose information:

* Hostname opendata.rdw.nl was found in DNS cache
*   Trying 52.16.222.96...
* TCP_NODELAY set
* Connected to opendata.rdw.nl (52.16.222.96) port 443 (#0)
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
    CApath: none
* SSL connection using TLSv1.0 / DHE-RSA-AES128-SHA
* Server certificate:
*  subject: OU=Domain Control Validated; CN=*.api.eu.socrata.com
*  start date: Feb 25 16:42:48 2016 GMT
*  expire date: Feb 25 16:42:48 2018 GMT
*  issuer: C=BE; O=GlobalSign nv-sa; CN=AlphaSSL CA - SHA256 - G2
*  SSL certificate verify ok.
> GET /resource/m9d7-ebf2.json?kenteken=49LZX9 HTTP/1.1
Host: opendata.rdw.nl
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5
Accept: */*

< HTTP/1.1 403 Forbidden
< Server: nginx
< Date: Wed, 16 Nov 2016 14:43:59 GMT
< Content-Type: text/html
< Content-Length: 162
< Connection: keep-alive
< 
* Curl_http_done: called premature == 0
* Connection #0 to host opendata.rdw.nl left intact

string(310) "HTTP/1.1 403 Forbidden Server: nginx Date: Wed, 16 Nov 2016 14:43:59 GMT Content-Type: text/html Content-Length: 162 Connection: keep-alive
403 Forbidden
nginx

Brand:

之前有谁见过这个?或者愿意帮助: - )

Thanx提前,Michiel

0 个答案:

没有答案