繁体   English   中英

用于Facebook Pages的graph.facebook.com

[英]graph.facebook.com for Facebook Pages

我目前正在一家互联网公司实习,他们想让我创建一个“品牌检查器”,以便访问者可以检查他们的品牌名称是否出现在Facebook,Twitter,LinkedIn等热门网站上。

我发现通过访问http://graph.facebook.com/可以查看Facebook上是否存在个人/帐户。 我目前正在尝试寻找一种方法来检查Facebook上是否存在某个页面。 我不需要发布之类的详细信息,只需要查找是否存在。

到目前为止,我已经尝试了下面的代码(注释的代码和未注释的代码),但根本不起作用。

<?php
/*$z = file_get_contents("http://www.facebook.com/search/results/?q=example");
preg_match("#LifeStamp#s", $z, $matches);
echo $matches[1];
if($matches == 1){
    echo "In there!";
    } elseif($matches == 0) {
    echo "No";
    } elseif($matches == "false") {
    echo "Nope";
    } else {
    echo "Nopenopenope";
    };*/
$ch = curl_init(); 
$timeout = 0; 
curl_setopt ($ch, CURLOPT_URL, 'http://www.facebook.com/search/results/?q=example'); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 
$file_contents = curl_exec($ch); 
curl_close($ch); 

var_dump($file_contents);
echo $file_contents[1];
?>

file_get_contents()给出错误( url_get_contents()url_get_contents() )。 curl -part仅返回空白页。

TL; DR:我可以通过一种(最好是简便的)方式检查Facebook页面是否存在吗? 而且,如果您碰巧知道的话,Twitter和LinkedIn也是如此。

提前致谢!

-Sean

您可以使用端点

https://graph.facebook.com/?id={url}

https://developers.facebook.com/docs/graph-api/reference/v2.2/url/中所示,以检查该URL是否存在object_id URL也可以是Facebook页面链接,例如

https://graph.facebook.com/?id=https://www.facebook.com/fgshdioghsdlfghsldfgkl

未采用的URL(-> Facebook Pages)的响应为

{
   "id": "https://www.facebook.com/fgshdioghsdlfghsldfgkl"
}

与以下Facebook页面相反:

https://graph.facebook.com/?id=https://www.facebook.com/cocacola

退货

{
   "id": "40796308305",
   "about": "The Coca-Cola Facebook Page is a collection of your stories showing how people from around the world have helped make Coke into what it is today.",
   "can_post": false,
   "category": "Food/beverages",
   "checkins": 13624,
   "cover": {
      "cover_id": "10152297032458306",
      "offset_x": 0,
      "offset_y": 0,
      "source": "https://fbcdn-sphotos-f-a.akamaihd.net/hphotos-ak-prn2/v/t1.0-9/s720x720/625442_10152297032458306_574021701_n.jpg?oh=4bcbc7e195383a2c41c99f2d9a76a41b&oe=54FFAEE9&__gda__=1426811392_edb8ee0782ce0143ba26abb724e7bc82",
      "id": "10152297032458306"
   },
   "description": "Created in 1886 in Atlanta, Georgia, by Dr. John S. Pemberton, Coca-Cola was first offered as a fountain beverage at Jacob's Pharmacy by mixing Coca-Cola syrup with carbonated water. \n\nCoca-Cola was patented in 1887, registered as a trademark in 1893 and by 1895 it was being sold in every state and territory in the United States. In 1899, The Coca-Cola Company began franchised bottling operations in the United States. \n\nCoca-Cola might owe its origins to the United States, but its popularity has made it truly universal. Today, you can find Coca-Cola in virtually every part of the world.\n\nCoca-Cola Page House Rules: http://CokeURL.com/q28a",
   "founded": "1886",
   "has_added_app": false,
   "is_community_page": false,
   "is_published": true,
   "likes": 91176186,
   "link": "https://www.facebook.com/coca-cola",
   "name": "Coca-Cola",
   "parking": {
      "lot": 0,
      "street": 0,
      "valet": 0
   },
   "talking_about_count": 1306671,
   "username": "coca-cola",
   "website": "http://www.coca-cola.com",
   "were_here_count": 0
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM