Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用discogs api删除bbcode的html标题_Php_Api_Header_Http Headers - Fatal编程技术网

Php 使用discogs api删除bbcode的html标题

Php 使用discogs api删除bbcode的html标题,php,api,header,http-headers,Php,Api,Header,Http Headers,我到处找,但找不到解决办法。。。如何解析discogs bbcode并将其转换为html,或者干脆将其删除 api正在返回大量非标准bbcode和discogs内部链接的乐队传记。。。如何将其解析为人类可读的文本,以便在我的网站上显示给最终用户 我在discogs论坛上问过,得到的答案是: If you don't want that specific format, you can include an Accept header in your response with your pref

我到处找,但找不到解决办法。。。如何解析discogs bbcode并将其转换为html,或者干脆将其删除

api正在返回大量非标准bbcode和discogs内部链接的乐队传记。。。如何将其解析为人类可读的文本,以便在我的网站上显示给最终用户

我在discogs论坛上问过,得到的答案是:

If you don't want that specific format, you can include an Accept header in your response with your preferred response type. We currently offer Discogs format (what you've got now), plaintext (URLs and other formatting is just stripped away), and HTML. For more information, see the API docs: https://www.discogs.com/developers/#page:home,header:home-versioning-and-media-types 
所以我尝试了这个,但没有成功:

curl_setopt($ch, CURLOPT_HTTPHEADER, array('application/vnd.discogs.v2.html+json')); 
这是我到目前为止所拥有的

$ch = curl_init(); //initialize the session 
curl_setopt($ch, CURLOPT_USERAGENT, 'APN/1.0 +https://www.anarcho-punk.net'); //Set the User-Agent Identifier 
curl_setopt($ch, CURLOPT_URL, $discogs_label_apiurl); //Set the URL of the page or file to download. 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  //Ask cURL to return the contents in a variable instead of simply echoing them 
//curl_setopt($ch, CURLOPT_HTTPHEADER, array('application/vnd.discogs.v2.html+json')); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('ACCEPT' => 'text/html'));
$output = curl_exec($ch); 

假设,您的内容确实应该是这样的:
curl\u setopt($ch,CURLOPT\u HTTPHEADER,array('ACCEPT'=>'application/vnd.discogs.v2.html+json')
(但我确实认为您需要像'curl\u setopt($ch,CURLOPT\u HTTPHEADER,array('ACCEPT'=>'text/html'))这样的不同内容,我刚刚测试过这个,仍然没有运气:(参见post editsee他们的文档:看起来第一个是正确的。(您的版本,前缀为ACCEPT.com,除非我做错了什么,否则curl_setopt($ch,CURLOPT_HTTPHEADER,array('ACCEPT'=>'application/vnd.discogs.v2.html+json');