Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.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
使用Algolia php库对某些请求(而不是其他请求)执行json解码错误_Php_Json_Algolia - Fatal编程技术网

使用Algolia php库对某些请求(而不是其他请求)执行json解码错误

使用Algolia php库对某些请求(而不是其他请求)执行json解码错误,php,json,algolia,Php,Json,Algolia,我看到以下错误: 我的情妇们 array (size=4) 'facets' => string 'Instock.1' (length=9) 'facetFilters' => string 'inStock.1:1' (length=11) 'numericFilters' => string 'itemId!=511283' (length=14) 'getRankingInfo' => int 1 如果我删除getRankingInfo或n

我看到以下错误:

我的情妇们

array (size=4)
  'facets' => string 'Instock.1' (length=9)
  'facetFilters' => string 'inStock.1:1' (length=11)
  'numericFilters' => string 'itemId!=511283' (length=14)
  'getRankingInfo' => int 1
如果我删除getRankingInfo或numericFilters,它适用于所有请求

根据Algolia中的日志,它会返回结果,但对于一些请求,我没有走那么远

导致出现错误的一个响应是:

请求

{
  "params": "facets=Instock.1&facetFilters=inStock.1%3A1&numericFilters=itemId%21%3D511283&getRankingInfo=1&query=WARBURTON+ORANGE+WRAPPER+800G"
}
回应

{
  "hits": [
    {
      "itemId": 506241,
      "name": "Warburton Blue Wrapper 800g",
      "slug": "506241-warburton-blue-wrapper",
      "brand": "Warburton",
      "supplier_name": "Warburtons Bread",
      "size": "800G",
      "status": "L",
      "vat_rate": "0.00",
      "popularity": 18992,
      "image": "/images/products/506241.jpg",
      "thumbnail": "/images/products/506241_thumbnail.jpg",
      "barcodes": [
        "5010044000039"
      ],
      "branches": [
        1,
        2,
        4,
        5,
        6
      ],
      "deepestCategory": "07013033337",
      "inStock": {
        "1": 1,
        "2": 0,
        "4": 1,
        "5": 1,
        "6": 1
      },
      "alternatives": [
      ],
      "objectID": "506241",
      "_highlightResult": {
        "name": {
          "value": "<em>Warburton</em> Blue <em>Wrapper</em> <em>800g</em>",
          "matchLevel": "partial",
          "matchedWords": [
            "warburton",
            "wrapper",
            "800g"
          ]
        },
        "barcodes": [
          {
            "value": "5010044000039",
            "matchLevel": "none",
            "matchedWords": [
            ]
          }
        ]
      },
      "_rankingInfo": {
        "nbTypos": 0,
        "firstMatchedWord": 0,
        "proximityDistance": 10,
        "userScore": 21542,
        "geoDistance": 0,
        "geoPrecision": 1,
        "nbExactWords": 3,
        "words": 3
      }
    },
    {
      "itemId": 511294,
      "name": "Warburton Green Wrapper ",
      "slug": "511294-warburton-green-wrapper",
      "brand": "Warburton",
      "supplier_name": "Warburtons Bread",
      "size": "",
      "status": "L",
      "vat_rate": "0.00",
      "popularity": 78098,
      "image": "/images/products/511294.jpg",
      "thumbnail": "/images/products/511294_thumbnail.jpg",
      "barcodes": [
        "5010044002347"
      ],
      "branches": [
        1,
        2,
        4,
        5,
        6
      ],
      "deepestCategory": "07013033337",
      "inStock": {
        "1":
{
  "hits": [
    {
      "itemId": 581691,
      "name": "I Can't Believe Its Not Butter 500g",
      "slug": "581691-i-cant-believe-its-not-butter",
      "brand": "I Can't Believe",
      "supplier_name": "U.lever Bestfoods (chilled)",
      "size": "500G",
      "status": "L",
      "vat_rate": "0.00",
      "popularity": 36597,
      "image": "/images/products/581691.jpg",
      "thumbnail": "/images/products/581691_thumbnail.jpg",
      "barcodes": [
        "000118039904",
        "05000118039904",
        "5000241007009"
      ],
      "branches": [
        1,
        2,
        3,
        4,
        5,
        6
      ],
      "deepestCategory": "07015269103",
      "inStock": {
        "1": 1,
        "2": 1,
        "3": 1,
        "4": 1,
        "5": 1,
        "6": 1
      },
      "alternatives": [
      ],
      "objectID": "581691",
      "_highlightResult": {
        "name": {
          "value": "<em>I</em> <em>Can't</em> <em>Believe</em> <em>Its</em> <em>Not</em> <em>Butter</em> 500g",
          "matchLevel": "partial",
          "matchedWords": [
            "i",
            "can",
            "t",
            "believe",
            "it",
            "s",
            "not",
            "butter"
          ]
        },
        "barcodes": [
          {
            "value": "000118039904",
            "matchLevel": "none",
            "matchedWords": [
            ]
          },
          {
            "value": "05000118039904",
            "matchLevel": "none",
            "matchedWords": [
            ]
          },
          {
            "value": "5000241007009",
            "matchLevel": "none",
            "matchedWords": [
            ]
          }
        ]
      },
      "_rankingInfo": {
        "nbTypos": 0,
        "firstMatchedWord": 0,
        "proximityDistance": 22,
        "userScore": 15914,
        "geoDistance": 0,
        "geoPrecision": 1,
        "nbExactWords": 6,
        "words": 8
      }
    },
    {
      "itemId": 247577,
      "name": "I Can't Believe Its Not Butter 250g"
回应

{
  "hits": [
    {
      "itemId": 506241,
      "name": "Warburton Blue Wrapper 800g",
      "slug": "506241-warburton-blue-wrapper",
      "brand": "Warburton",
      "supplier_name": "Warburtons Bread",
      "size": "800G",
      "status": "L",
      "vat_rate": "0.00",
      "popularity": 18992,
      "image": "/images/products/506241.jpg",
      "thumbnail": "/images/products/506241_thumbnail.jpg",
      "barcodes": [
        "5010044000039"
      ],
      "branches": [
        1,
        2,
        4,
        5,
        6
      ],
      "deepestCategory": "07013033337",
      "inStock": {
        "1": 1,
        "2": 0,
        "4": 1,
        "5": 1,
        "6": 1
      },
      "alternatives": [
      ],
      "objectID": "506241",
      "_highlightResult": {
        "name": {
          "value": "<em>Warburton</em> Blue <em>Wrapper</em> <em>800g</em>",
          "matchLevel": "partial",
          "matchedWords": [
            "warburton",
            "wrapper",
            "800g"
          ]
        },
        "barcodes": [
          {
            "value": "5010044000039",
            "matchLevel": "none",
            "matchedWords": [
            ]
          }
        ]
      },
      "_rankingInfo": {
        "nbTypos": 0,
        "firstMatchedWord": 0,
        "proximityDistance": 10,
        "userScore": 21542,
        "geoDistance": 0,
        "geoPrecision": 1,
        "nbExactWords": 3,
        "words": 3
      }
    },
    {
      "itemId": 511294,
      "name": "Warburton Green Wrapper ",
      "slug": "511294-warburton-green-wrapper",
      "brand": "Warburton",
      "supplier_name": "Warburtons Bread",
      "size": "",
      "status": "L",
      "vat_rate": "0.00",
      "popularity": 78098,
      "image": "/images/products/511294.jpg",
      "thumbnail": "/images/products/511294_thumbnail.jpg",
      "barcodes": [
        "5010044002347"
      ],
      "branches": [
        1,
        2,
        4,
        5,
        6
      ],
      "deepestCategory": "07013033337",
      "inStock": {
        "1":
{
  "hits": [
    {
      "itemId": 581691,
      "name": "I Can't Believe Its Not Butter 500g",
      "slug": "581691-i-cant-believe-its-not-butter",
      "brand": "I Can't Believe",
      "supplier_name": "U.lever Bestfoods (chilled)",
      "size": "500G",
      "status": "L",
      "vat_rate": "0.00",
      "popularity": 36597,
      "image": "/images/products/581691.jpg",
      "thumbnail": "/images/products/581691_thumbnail.jpg",
      "barcodes": [
        "000118039904",
        "05000118039904",
        "5000241007009"
      ],
      "branches": [
        1,
        2,
        3,
        4,
        5,
        6
      ],
      "deepestCategory": "07015269103",
      "inStock": {
        "1": 1,
        "2": 1,
        "3": 1,
        "4": 1,
        "5": 1,
        "6": 1
      },
      "alternatives": [
      ],
      "objectID": "581691",
      "_highlightResult": {
        "name": {
          "value": "<em>I</em> <em>Can't</em> <em>Believe</em> <em>Its</em> <em>Not</em> <em>Butter</em> 500g",
          "matchLevel": "partial",
          "matchedWords": [
            "i",
            "can",
            "t",
            "believe",
            "it",
            "s",
            "not",
            "butter"
          ]
        },
        "barcodes": [
          {
            "value": "000118039904",
            "matchLevel": "none",
            "matchedWords": [
            ]
          },
          {
            "value": "05000118039904",
            "matchLevel": "none",
            "matchedWords": [
            ]
          },
          {
            "value": "5000241007009",
            "matchLevel": "none",
            "matchedWords": [
            ]
          }
        ]
      },
      "_rankingInfo": {
        "nbTypos": 0,
        "firstMatchedWord": 0,
        "proximityDistance": 22,
        "userScore": 15914,
        "geoDistance": 0,
        "geoPrecision": 1,
        "nbExactWords": 6,
        "words": 8
      }
    },
    {
      "itemId": 247577,
      "name": "I Can't Believe Its Not Butter 250g"
{
“点击次数”:[
{
“项目ID”:581691,
“名字”:“我不敢相信它不是500克黄油”,
“鼻涕虫”:“581691-i-cant-Truse-its-not-butter”,
“品牌”:“我不敢相信”,
“供应商名称”:“U.lever Bestfoods(冷冻)”,
“尺寸”:“500G”,
“状态”:“L”,
“增值税税率”:“0.00”,
“人气”:36597,
“图像”:“/images/products/581691.jpg”,
“缩略图”:“/images/products/581691_thumbnail.jpg”,
“条形码”:[
"000118039904",
"05000118039904",
"5000241007009"
],
“分支机构”:[
1.
2.
3.
4.
5.
6.
],
“最深类别”:“07015269103”,
“inStock”:{
"1": 1,
"2": 1,
"3": 1,
"4": 1,
"5": 1,
"6": 1
},
“备选方案”:[
],
“objectID”:“581691”,
“_highlightResult”:{
“姓名”:{
“价值”:“我不敢相信它不是500克黄油”,
“匹配级别”:“部分”,
“匹配词”:[
“我”,
“可以”,
“t”,
“相信”,
“它”,
“s”,
“不是”,
“黄油”
]
},
“条形码”:[
{
“值”:“000118039904”,
“匹配级别”:“无”,
“匹配词”:[
]
},
{
“值”:“0500018039904”,
“匹配级别”:“无”,
“匹配词”:[
]
},
{
“价值”:“5000241007009”,
“匹配级别”:“无”,
“匹配词”:[
]
}
]
},
“_rankingInfo”:{
“nbTypos”:0,
“firstMatchedWord”:0,
“近距离”:22,
“用户分数”:15914,
“大地距离”:0,
“地质精度”:1,
“nbExactWords”:6,
“词语”:8
}
},
{
“项目ID”:247577,
“名字”:“我不敢相信它不是250克黄油”

结果集似乎导致json_解码出错。当我将命中率限制为10时,一切正常。因此,这里的答案是对大集合进行分页,这是显而易见的


感谢所有阅读和评论的人。

您的代码/问题到底是什么?因为在所附的屏幕截图1)中显示了json_decode()的错误,在第二个屏幕截图中显示了json_encode()的代码。因此,您可以检查您的json_encode()的代码吗工作正常?结果是什么?我认为错误在于返回语句。我在stacktrace顶部添加了第一个错误的另一个屏幕截图。第三个是发生之前的文件。只是尝试提供更多图片。但是您在返回语句中说的错误$res是什么。请用您的屏幕截图澄清。或者把你的完整代码放进去。我添加了请求和响应json以获得成功和失败。代码方面,这是algolia php库。我在上面粘贴的两个请求/响应部分使用的代码都是相同的。这可能很简单,因为它为jsonDecode返回了太多的信息,我只是将其限制为10(无论如何都应该是这样)它成功了。我在确认之前正在检查。