Json 403在socrata查询opendata时出错

Json 403在socrata查询opendata时出错,json,curl,http-status-code-403,socrata,Json,Curl,Http Status Code 403,Socrata,我正在索克拉塔的一个开放数据源中查询数据 目标是通过输入牌照来检索有关车辆的一些信息。代码运行得很好,但是几天前它停止了工作 //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(); $time

我正在索克拉塔的一个开放数据源中查询数据

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

//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;
//条形牌照,只能包含A-Z和0-9。6个字符长:1xx11
$kent=strtoupper(预替换(“/[^a-zA-Z0-9]+/”,“,$”获得['kent'));
//开始卷曲
$curl=curl_init();
$timeout=30;
$ret='';
$url='1https://opendata.rdw.nl/resource/m9d7-ebf2.json?kenteken=“.$kent;
curl_setopt($curl,CURLOPT_URL,$URL);
curl_setopt($curl,CURLOPT_头,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;windowsnt 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);
//伐木
$verbose=fopen('php://temp","w+",;
curl_setopt($curl,CURLOPT_STDERR,$verbose);
$gegevens=curl\u exec($curl);
//关上把手
curl_close($curl);
倒带($verbose);
$verboseLog=stream\u get\u contents($verbose);
//打印日志
回显“详细信息:\n”,htmlspecialchars($verboseLog),“\n”;
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:
//数据消除 $text=json_decode($gegevens,true); $merk=$text[0]['merk']; $type=$text[0]['handelsbenaming']; echo“品牌:.$merk..”$type;
运行此文件会给我留下:

详细信息:
*在DNS缓存中找到主机名opendata.rdw.nl
*正在尝试52.16.222.96。。。
*TCP_节点集
*已连接到opendata.rdw.nl(52.16.222.96)端口443(#0)
*密码选择:全部:!出口:!出口40:!出口56:!阿努尔:!低:!RC4:@强度
*已成功设置证书验证位置:
*CAfile:/etc/pki/tls/certs/ca-bundle.crt
卡帕斯:没有
*使用TLSv1.0/DHE-RSA-AES128-SHA的SSL连接
*服务器证书:
*主题:OU=已验证的域控制;CN=*.api.eu.socrata.com
*开始日期:2016年2月25日16:42:48 GMT
*到期日期:2018年2月25日格林尼治标准时间16:42:48
*发行人:C=BE;O=全球信号内华达州;CN=AlphaSSL CA-SHA256-G2
*SSL证书验证正常。
>GET/resource/m9d7-ebf2.json?kenteken=49lzx9http/1.1
主机:opendata.rdw.nl
用户代理:Mozilla/5.0(Windows;U;Windows NT 6.0;en-US;rv:1.9.0.5)Gecko/2008120122 Firefox/3.0.5
接受:*/*
谁曾经遇到过这种情况?或者愿意帮助:-)


Thanx提前,Michiel

403表示需要登录或您提供的凭据无效?我将我的应用令牌放在curl标题“X-app-token:HEREIPUTMYTOKEN”中“。我也认为这可能是事实,但是创建一个新的代币并没有什么不同。有人能解释这一点吗?”?如果仅在浏览器中运行查询,则会得到正确的输出。403表示需要登录或您提供的凭据无效?我将我的应用令牌放在curl标题“X-app-token:HEREIPUTMYTOKEN”中。我也认为这可能是事实,但是创建一个新的代币并没有什么不同。有人能解释这一点吗?如果仅在浏览器中运行查询,则会得到正确的输出。