forked from friendica/php-json-ld
Make default url resolver a separate function.
This commit is contained in:
parent
7b20e349af
commit
4c76b11a67
22
jsonld.php
22
jsonld.php
|
@ -171,13 +171,25 @@ function jsonld_resolve_url($url) {
|
||||||
return call_user_func($jsonld_default_url_resolver, $url);
|
return call_user_func($jsonld_default_url_resolver, $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// default JSON-LD GET implementation
|
||||||
|
return jsonld_default_resolve_url($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default implementation to retrieve JSON-LD at the given URL.
|
||||||
|
*
|
||||||
|
* @param string $url the URL to to resolve.
|
||||||
|
*
|
||||||
|
* @return the JSON-LD.
|
||||||
|
*/
|
||||||
|
function jsonld_default_resolve_url($url) {
|
||||||
// default JSON-LD GET implementation
|
// default JSON-LD GET implementation
|
||||||
$opts = array('http' =>
|
$opts = array('http' =>
|
||||||
array(
|
array(
|
||||||
'method' => "GET",
|
'method' => "GET",
|
||||||
'header' =>
|
'header' =>
|
||||||
"Accept: application/ld+json\r\n" .
|
"Accept: application/ld+json\r\n" .
|
||||||
"User-Agent: PaySwarm PHP Client/1.0\r\n"));
|
"User-Agent: PaySwarm PHP Client/1.0\r\n"));
|
||||||
$stream = stream_context_create($opts);
|
$stream = stream_context_create($opts);
|
||||||
$result = @file_get_contents($url, false, $stream);
|
$result = @file_get_contents($url, false, $stream);
|
||||||
if($result === false) {
|
if($result === false) {
|
||||||
|
|
Loading…
Reference in a new issue