首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在socrata查询opendata 403错误

在socrata查询opendata 403错误
EN

Stack Overflow用户
提问于 2018-12-11 04:19:05
回答 1查看 0关注 0票数 0

我在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:

以前谁遇到过这个?或者愿意帮助:-)

EN

回答 1

Stack Overflow用户

发布于 2018-12-11 14:07:43

我能够从https://opendata.rdw.nl/resource/m9d7-ebf2.json检索数据,而不提供任何TOKEN信息。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100005127

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档