所以我在这里为PHP写了这个脚本,因为我找不到任何关于它的东西。 这样做是为了获取Facebook的缩略图图像代码并显示它。我的问题是在显示它们之前测试这些图像是否确实存在,因为Facebook默认为问号图像,我无法测试损坏的链接。如果我所引用的问号不存在,我将如何唯一地识别Facebook返回的问号图像?
//define our test subject
$testvar = "[[490550790968952]][[490550800968951]][[490550807635617]]
[[490550820968949]][[490550837635614]][[490550847635613]]
[[490550857635612]][[490550867635611]][[490550877635610]]
[[490550884302276]][[490550894302275]][[490550900968941]]
[[490550914302273]][[490550924302272]][[490550937635604]]
[[490550947635603]][[490550954302269]][[490550967635601]]";
//this one is a broken link and generates the question mark, remove this line to test the above code
$testvar = "[[171108522930776]]";
//convert new lines to <br>
$testvar = nl2br($testvar);
//replace all numbers with links
$numfilter = "/([0-9]){1,}/"; //match all number blocks without brackets
$testvar = preg_replace($numfilter, "<img src='https://graph.facebook.com/\\0/picture'>", $testvar);
//strip the brackets
$stripbrackets = array("[[","]]");
$testvar = str_replace($stripbrackets,"",$testvar);
//echo a div with the output, setting font-size:0 so the <br> tags don't create vertical spacing between new lines
echo "<div style='font-size:0px; line-height:0px;'>";
echo $testvar;
echo "</div>";
?>
答案 0 :(得分:1)
is_silhouette
字段。看一下这个结果:https://graph.facebook.com?fields=name,picture&ids=490550790968952,171108522930776
如果你使用cURL进入PHP,然后json_decode()
这个结果,你将能够遍历它并测试每个id,看看它是否是Facebook的未定义图像之一