PHP->;JSON响应,想要按关键字过滤-500错误


PHP -> JSON Response, Wanting To Filter By Key Word - 500 Error?

PHP->JSON

所以我调用了一个在线服务,它返回一个我正在解码的JSON。然后,对于每条记录,我对一个字段执行STRPOS,如果!==FALSE,我希望它显示记录,否则转到下一个记录。

问题:如果没有STRPOS,所有代码都可以工作并且不会超时。有了STRPOS,我得到了一个500的错误。

是我的代码(效率低下(还是服务让我超时了?想法?

提前感谢!

$jsonFile = file_get_contents('https://api.website.com/file.json');
$json_outputa = json_decode($jsonFile);
foreach ( $json_outputa->divisions as $division )
{   
$jsondeal = file_get_contents('https://api.website.com/specifics.json?division_id=' . $division->id . '&filters=category:' . $category . '&limit=20');
$jsondeal_output = json_decode($jsondeal);
foreach ( $jsondeal_output->deals as $deal )
{
    If ($deal->tags)
    {
        If (strpos($deal->Title, $searchstring) !== false)
        {
            ?>
                    <tr>
!! NOW DO STUFF !!

*!工作并返回到UI的代码。只是删除了STRPOS的IF。

$jsonFile = file_get_contents('https://api.website.com/file.json');
$json_outputa = json_decode($jsonFile);
foreach ( $json_outputa->divisions as $division )
{   
$jsondeal = file_get_contents('https://api.website.com/specifics.json?division_id=' . $division->id . '&filters=category:' . $category . '&limit=20');
$jsondeal_output = json_decode($jsondeal);
foreach ( $jsondeal_output->deals as $deal )
{
If ($deal->tags)
{
           ?>

我想这是你的链接https://api.website.com/file.json尝试在浏览器中打开它,它显示找不到404文件。

尝试本地json或类似的有效json文件

http://www.json-generator.com/api/json/get/cbvSOJYRbC?indent=2