这是youtube api(https://www.youtube.com/oembed?format=json&url=https://www.youtube.com/watch?v=EeVIPLzui7M)的回应
当我尝试像这样解码时
<?php
echo json_decode('{"provider_name": "YouTube", "version": "1.0", "html": "\u003ciframe width=\"480\" height=\"270\" src=\"https:\/\/www.youtube.com\/embed\/EeVIPLzui7M?feature=oembed\" frameborder=\"0\" allowfullscreen\u003e\u003c\/iframe\u003e", "provider_url": "https:\/\/www.youtube.com\/", "thumbnail_url": "https:\/\/i.ytimg.com\/vi\/EeVIPLzui7M\/hqdefault.jpg", "type": "video", "thumbnail_height": 360, "author_url": "https:\/\/www.youtube.com\/channel\/UCCfkNoFDIRnITBg9J4hSdZw", "thumbnail_width": 480, "height": 270, "width": 480, "author_name": "\u0627\u0644\u063a\u0632\u0627\u0629 \u0104\u0141J\u00d8\u0151\u00d8\u0136\u0158", "title": "\u0627\u0644\u0628\u0637\u0648\u0644\u0629 \u0627\u0644\u0643\u0628\u0631\u0649 * \u062a\u062d\u0627\u0644\u0641 \u062f\u0642 \u062e\u0634\u0648\u0645 \u00d7 \u0643\u062a\u064a\u0628\u0629 \u0627\u0639\u062f\u0627\u0627\u0645 \U0001f60e \u062f\u0639\u0633 \U0001f451\u274c"}',true);
它什么也没给我
有人知道为什么吗?
最佳答案
仅在浏览器中打开https://www.youtube.com/oembed?format=json&url=https://www.youtube.com/watch?v=EeVIPLzui7M#
会显示JSON语法错误(因为我具有浏览器扩展来呈现JSON)。json_decode
返回NULL,因为您要传递给它的不是JSON。大概是由于YouTube上的错误所致。
关于php - json_decode无法解码字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35956442/