【发布时间】:2014-03-29 06:59:30
【问题描述】:
不要浪费一秒钟,看看这段代码:
$gp=$_GET["gp"];
function googleplus($gp) {
$furl = "http://query.yahooapis.com/v1/public/yql?q=SELECT * from html where url='https://plus.google.com/%252B".$gp."' AND xpath=\"//div[@class='Nn']//div[@class='rw Uc']//div[@class='Zi']//div[@class='V9b nhe']//div[@class='tQE8Kd BnqoOb']//div[@class='Qhb eZa']//div[@class='vkb']//p\"&format=xml";
$api = simplexml_load_file($furl);
$followers = $api->results->p;
return $followers;
}
好的。当我这样做时
<?php echo googleplus($gp); ?>
在 URL 中带有参数 gp=mehulmohan,它应该返回如下内容:
539 让他转圈
检查与 mehulmohan 关联的 URL
但实际上,它返回空白。为什么?
请帮忙。所有其他社交媒体(如 pinterest 和 twitter)都返回正确的结果,但 Google+ 返回空白。
注意点:我在 URL 中解析了 2 次“+”符号,就像 1 次一样,它不接受 XML,而是第二次。
"+" = %2B = %252B
【问题讨论】:
标签: php xml api google-plus