验证Facebook页面URL [英] Validate a Facebook page URL
问题描述
对于我正在开发的应用程序,我们允许用户将链接添加到其Facebook页面(严格为页面,不是个人资料,不是组,而是页面).
For an application I am developing, we allow users to add a link to their Facebook Page (strictly page, not Profile, not Group, only a Page).
我找不到有关验证我收到的URL(服务器端,PHP)是否实际上是有效的页面URL的任何信息.
I cannot find anything about validating whether the URL I received (server-side, PHP) is actually a valid Page URL.
如果我能获得真实的" URL信息,即减去#,那就更好了!如果有一个.我可以通过一些解析来管理它,但我宁愿Facebook告诉我.
Even better if I can get the "true" URL information, i.e. minus the #! if there is one. I can manage this with some parsing but I'd rather Facebook tell me.
推荐答案
我有类似的任务,首先我要求Facebook提供标准化的URL(不带!#等):
I have the similar task, first I ask Facebook for normalized URL (without !#, etc):
require_once('facebook.php');
function getNormalized($anylink){
$facebook = new Facebook(array(
'appId' => 'yourapplicationID',
'secret' => 'yoursecretcode',
'cookie' => true,
));
$res = $facebook->api(array(
'method' => 'fql.query',
'query' => 'select url, normalized_url from link_stat where url = "'.$anylink.'" ;'
));
if (!isset($res[0]['normalized_url']))
{
//If not isset -> set with dumy value, example
echo '<br>You have not entered Facebook Page URL or its not accessible. Please go back and try again.';
exit;
}
return $res;
}
这篇关于验证Facebook页面URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!