Right now I have a html built website with bootstrap and my bludit blog in a sub directory named blog.
In the past with an older version of Bludit I was able to do it with help from this post:
viewtopic.php?t=917
But now the same code doesn't work for some reason. Can I still do this or has the api changed since the original working code?
Code: Select all
<?php
$url = 'https://www.mywebsite.com/blog/api/show/all/pages/f3fd2843709dcc49d6ebf2efe01ec460';
$jsonData = file_get_contents($url);
$data = json_decode($jsonData, true);
$i = 1;
foreach($data as $post) {
if($i <= 5) {
$postPermalink = $post['permalink'];
$postTitle = $post['title'];
echo '<a class="post-link" href="'.$postPermalink.'">'.$postTitle.'</a>';
echo '<br>';
$i++;
}
else {
break;
}
}
?>
Also is allow_url_fopen supposed to be enabled? I was seeing the wrapper disabled error in my logs referencing this so I enabled it against my better judgement due to the serious security concerns.[11-Jun-2020 04:16:07 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/mywebsite/public_html/index.php on line 287
[11-Jun-2020 04:16:07 UTC] PHP Warning: file_get_contents(https://www.mywebsite.com/blog/api/show ... efe01ec460): failed to open stream: no suitable wrapper could be found in /home/mywebsite/public_html/index.php on line 287
[11-Jun-2020 04:16:07 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/mywebsite/public_html/index.php on line 293
The disabled wrapper error disappeared but the invalid foreach argument was still there and it didn't seem to make a difference so I disabled it again.