从记事本文件中列出的个人资料网址获取Facebook用户ID

时间:2015-09-09 12:26:45

标签: php facebook facebook-graph-api facebook-javascript-sdk facebook-php-sdk

我看过很多网站/脚本从个人资料网址中检索Facebook UID。 (lookup-id.com,findmyfbid.com等)。我的问题是,如果我在记事本文件中列出了多个配置文件ID(url),是否可以通过运行带有程序或脚本的循环来获取所有URL的UID?

我搜索了这个和其他几个网站,但没有得到相关信息或代码可以操作一点来满足我的要求。

在这里感谢一些帮助。

由于

2 个答案:

答案 0 :(得分:1)

您可以使用fopen从文本文件中获取网址,例如:

<?php

$fh = fopen('file_name.txt','r');
while ($line = fgets($fh)) {
  // echo($line);
  // your code to fetch facebook id
}
fclose($fh);

?>

或使用file_get_contents

<?php
$array = explode("\n", file_get_contents('file_name.txt'));
//this will return you an array, loop through the array and your code to get fb id
?>

答案 1 :(得分:0)

如果您只想获取数字:

<?php
$line = explode("\n", file_get_contents('file_name.txt'));

foreach($line as $string){

   $id = preg_replace("/[^0-9]/", "", $string); //remove all non-numeric characters

   //if empty, nothing :)
   if(!$id){  
   }

   //otherwise, print result with linebreak
   else{
   echo $id."<br/>"; //only result is numbers
   }

}

在这种情况下,file_name.txt包含以下行:

facebook.com/1
facebook.com/2
facebook.com/3
facebook.com/4
http://www.facebook.com/5
www.facebook.com/6

输出现在是:

1
2
3
4
5
6