本文整理汇总了PHP中ARC2::getJSONParser方法的典型用法代码示例。如果您正苦于以下问题:PHP ARC2::getJSONParser方法的具体用法?PHP ARC2::getJSONParser怎么用?PHP ARC2::getJSONParser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ARC2
的用法示例。
在下文中一共展示了ARC2::getJSONParser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: curl_setopt
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: text/turtle, text/n3; q=0.9, application/turtle; q=0.8, application/n-triples; q=0.7, application/rdf+xml; q=0.6, application/json; q=0.4, */*; q=0.1"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
$_aux = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
$_aux2 = explode(";", $_aux);
$content_type = array_shift($_aux2);
curl_close($ch);
$parser = NULL;
$parsers = array();
$parsers[0]['formats'] = array('text/n3', 'application/x-turtle', 'application/turtle', 'text/turtle');
$parsers[0]['parser'] = ARC2::getTurtleParser();
$parsers[1]['formats'] = array('application/rdf+xml');
$parsers[1]['parser'] = ARC2::getRDFXMLParser();
$parsers[2]['formats'] = array('application/json', 'application/x-javascript', 'text/javascript', 'text/x-javascript', 'text/x-json');
$parsers[2]['parser'] = ARC2::getJSONParser();
foreach ($parsers as $v) {
if (in_array($content_type, $v['formats'])) {
$parser = $v['parser'];
}
}
//If nothing fits, pray to your favorite god that this can be detected and parsed correctly by ARC2.
$parser = ARC2::getRDFParser();
//end of workaround
$parser->parse($u, $data);
//Since IDK which namespace the documents contains, lets use the uri requested
$triples = $parser->getTriples();
$first = true;
$c = 0;
$nodes = array();
$literals = array();