Hi,
I'm new to this forum but i think i can contribute alot
I've created a pretty simple PHP script that add's friends to your account based on a given group (you just give it the group id).
I don't know if there are stuff like that out there or if it interest anybody so tell me if it does i will post it here somewhere.
Plus i didn't know if i should post it where a gazillion of users can see it.
Thanks,
kod.
P.S. i just started browsing the forums i'm sure i have alot of snippets for other parts of the site
[27/08/2009] - UPDATED
ok i've decided to put the code here i guess it needs some modifications and a little bit of knowledge to run it so here goes:
Its 2 scripts (for somereason when i try to automate it to one script facebook dosen't let me add friends):
facebook_links_fetcher.php
This script will generate a list of add friends links. you then need to go the my other script which will display a textarea box inwhich you will need to paste the links you got from the first scripts
facebook_frinds_adder.php
If anyone have any suggestions about how to earn some money out of this or any other scripts PM me i'm clueless but i have some coding skillz
Thanks,
kod
I'm new to this forum but i think i can contribute alot
I've created a pretty simple PHP script that add's friends to your account based on a given group (you just give it the group id).
I don't know if there are stuff like that out there or if it interest anybody so tell me if it does i will post it here somewhere.
Plus i didn't know if i should post it where a gazillion of users can see it.
Thanks,
kod.
P.S. i just started browsing the forums i'm sure i have alot of snippets for other parts of the site
[27/08/2009] - UPDATED
ok i've decided to put the code here i guess it needs some modifications and a little bit of knowledge to run it so here goes:
Its 2 scripts (for somereason when i try to automate it to one script facebook dosen't let me add friends):
facebook_links_fetcher.php
PHP:
<?PHP
ob_start();
set_time_limit(0);
/*
* YOU FACEBOOK LOGIN INFORMATION
*/
$login_email = '';
$login_pass = '';
$group_id = '36962602451';
$path_to_server = 'c://inetpub//mywebsite';
$page = curlFetchPage($login_email, $login_pass, 'http://m.facebook.com/s.php?r20b2ee58&id='.$group_id.'&k=100000004&gr=2&act=2374053504&refid=26');
exit;
function FindFriendLink($data) {
$addfriendPat = '/addfriend.php';
$poss = strpos($data,$addfriendPat);
$firsttrim = substr($data,$poss,strlen($data));
$sposs = strpos($firsttrim,'"');
$findit = substr($firsttrim,0,$sposs);
$firsttrim = substr($firsttrim,200,strlen($firsttrim));
return array($findit,$firsttrim);
}
function curlFetchPage($user,$pass,$link,$loginlink = 'https://login.facebook.com/login.php?m&next=http%3A%2F%2Fm.facebook.com%2Fhome.php') {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $loginlink);
curl_setopt($ch, CURLOPT_POSTFIELDS,'email='.urlencode($user).'&pass='.urlencode($pass).'&login=Login');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, "{$path_to_server}//my_cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "{$path_to_server}//my_cookies.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
curl_exec($ch);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com/findfriends.php?ra67f823f&view=pymk&refid=1');
curl_exec($ch);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'message=Hello&add="Add as Friend"');
curl_setopt($ch, CURLOPT_URL, $link);
$page = curl_exec($ch);
//echo 'Went to: '.$link.'<br />';
$original_page = $page;
$visited = array('Prev',2);
$count = 1;
$all_links = array();
//need to parse some links and go to link number 2
$nextLink = getNextLink($page);
$finished = false;
while (strpos($nextLink[0],'/s.php') && !$finished) {
//$nextLink = 'http://m.facebook.com'.$nextLink;
$nextLink[0] = str_replace('&','&',$nextLink[0]);
//echo 'found nextLink: '.$nextLink[0].'<br />';
$links = array();
$test = FindFriendLink($page);
while (strpos($test[0],'addfriend.php')) {
$page = $test[1];
array_push($links,$test[0]);
array_push($all_links,$test[0]);
$test = FindFriendLink($page);
}
foreach ($links as $link) {
//$link = '\'http://m.facebook.com'.$link.'\',<br />';
$link = 'http://m.facebook.com'.$link.'<br />';
echo str_replace('addfriend.php','connect.php',$link);
}
ob_flush();
flush();
if (strpos($page,"Â ".$pushin."Â ")) {
$finished = true;
}
//http://m.facebook.com/s.php
//$firsttrim = substr($firsttrim,200,strlen($firsttrim));
//echo 'Done parsing links.. Going to next link: '.$nextLink[0]."<br />";
sleep(1);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'message=Hello&add="Add as Friend"');
curl_setopt($ch, CURLOPT_URL, $nextLink[0]);
$page = curl_exec($ch);
//var_dump(strlen($page));
if (!$finished) {
if (strlen($page) < 3000) {
//if (strpos($page,"Sorry, an error has occurred")) {
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'message=Hello&add="Add as Friend"');
curl_setopt($ch, CURLOPT_URL, $nextLink[0]);
$page = curl_exec($ch);
//}
}
//echo 'nextLink before: '.$nextLink[0].'<br />';
$nextLink = getNextLink($page);
if ($found = in_array($nextLink[1],$visited)) {
//bad neext to find bigger next link
$pattern = '">'.$count;
$count++;
$pushin = $count + 1;
array_push($visited,$pushin);
//var_dump($pattern);
$findnew = strpos($page,$pattern);
//var_dump($findnew);
$page_changed = substr($page,$findnew,strlen($page));
$nextLink = getNextLink($page_changed);
//var_dump($page_changed);
//die("Ab");
} else {
$finished = true;
}
}
//echo 'nextLink after: '.$nextLink[0].'<br />';
//var_dump($nextLink);
//die("A");
}
/*$original_page = $page;
$test = FindFriendLink($page);
while (strpos($test[0],'addfriend.php')) {
$page = $test[1];
array_push($links,$test[0]);
$test = FindFriendLink($page);
}
foreach ($links as $link) {
//$link = '\'http://m.facebook.com'.$link.'\',<br />';
$link = 'http://m.facebook.com'.$link.'<br />';
echo str_replace('addfriend.php','connect.php',$link);
}*/
echo "found: ".count($all_links)." add links";
//var_dump($links);
die("A");
return $page;
}
function getNextLink($data) {
$addfriendPat = 'http://m.facebook.com/s.php';
$poss = strpos($data,$addfriendPat);
$firsttrim = substr($data,$poss,strlen($data));
$sposs = strpos($firsttrim,'"');
$findit = substr($firsttrim,0,$sposs);
$firsttrim = substr($firsttrim,$sposs+2,strlen($firsttrim));
$findnext = strpos($firsttrim,'</a>');
$linkpage = substr($firsttrim,0,$findnext);
//echo 'found find it:'.$findit.'<br />';
//echo 'found linkpage:'.$linkpage.'<br />';
//die("A");
return array($findit,$linkpage);
}
function curlFetchPagePost($user,$pass,$link,$loginlink = 'https://login.facebook.com/login.php?m&next=http%3A%2F%2Fm.facebook.com%2Fhome.php') {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $loginlink);
curl_setopt($ch, CURLOPT_POSTFIELDS,'email='.urlencode($user).'&pass='.urlencode($pass).'&login=Login');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, "{$path_to_server}//my_cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "{$path_to_server}//my_cookies.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
curl_exec($ch);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, $link);
$firstpage = curl_exec($ch);
preg_match('/name="post_form_id" value="(.*)" \/>/', $firstpage, $form_id);
$form_id[1] = substr($form_id[1],0,strpos($form_id[1],'"'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'post_form_id='.$form_id[1].'&message=Hello&add="Add as Friend"');
curl_setopt($ch, CURLOPT_URL, $link);
$page = curl_exec($ch);
return $page;
}
?>
facebook_frinds_adder.php
PHP:
<?PHP
$path_to_server = 'c://inetpub//mywebsite';
if (isset($_POST['list'])) {
set_time_limit(0);
ob_start();
$login_email = '';
$login_pass = '';
$page = curlFetchPage($login_email,$login_pass,'http://m.facebook.com/findfriends.php?ra67f823f&view=pymk&refid=1');
if (is_array($links)) {
if (count($links) > 1) {
echo 'Got Links from facebook-links.php<br />';
} else {
die("Didnot got links");
}
} else {
die("Didnot got links");
}
echo 'sleeping 2 seconds ?<br />';
ob_flush();
flush();
sleep(2);
ob_flush();
flush();
$links = explode(PHP_EOL,$_POST['list']);
foreach ($links as $link) {
$link = trim($link);
echo 'Going to: '.$link.'<br />';
$spage = curlFetchPagePost($login_email,$login_pass,$link);
if (strpos($spage,'Warning! You are engaging in behavior')) {
die("<h1>Facebook is on to you !!! :)</h1>");
}
$findme = '<div class="notice">';
$firstit = strpos($spage,$findme);
$result = substr($spage,$firstit+strlen($findme),strlen($spage));
$result = substr($result,0,strpos($result,'</div>'));
echo $result.'<br />';
$fp = fopen("facebook.log","a+");
fwrite($fp,$spage.PHP_EOL);
fclose($fp);
$sleepNum = rand(150,180);
echo "sleeping for {$sleepNum} seconds";
ob_flush();
flush();
sleep($sleepNum);
}
curl_close($ch);
}
echo '<html><head></head><body><form method="post"><textarea name="list"></textarea><input type="submit" /></form></body><html>';
function FindFriendLink($data) {
$addfriendPat = '/addfriend.php';
$poss = strpos($data,$addfriendPat);
$firsttrim = substr($data,$poss,strlen($data));
$sposs = strpos($firsttrim,'"');
$findit = substr($firsttrim,0,$sposs);
$firsttrim = substr($firsttrim,200,strlen($firsttrim));
return array($findit,$firsttrim);
}
function curlFetchPage($user,$pass,$link,$loginlink = 'https://login.facebook.com/login.php?m&next=http%3A%2F%2Fm.facebook.com%2Fhome.php') {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $loginlink);
curl_setopt($ch, CURLOPT_POSTFIELDS,'email='.urlencode($user).'&pass='.urlencode($pass).'&login=Login');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, "{$path_to_server}//my_cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "{$path_to_server}//my_cookies.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
curl_exec($ch);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com/findfriends.php?refid=1');
curl_exec($ch);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'message=Hello&add="Add as Friend"');
curl_setopt($ch, CURLOPT_URL, $link);
$page = curl_exec($ch);
return $page;
}
function curlFetchPagePost($user,$pass,$link,$loginlink = 'https://login.facebook.com/login.php?m&next=http%3A%2F%2Fm.facebook.com%2Fhome.php') {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $loginlink);
curl_setopt($ch, CURLOPT_POSTFIELDS,'email='.urlencode($user).'&pass='.urlencode($pass).'&login=Login');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, "{$path_to_server}//my_cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "{$path_to_server}//my_cookies.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
curl_exec($ch);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, $link);
$firstpage = curl_exec($ch);
preg_match('/name="post_form_id" value="(.*)" \/>/', $firstpage, $form_id);
$form_id[1] = substr($form_id[1],0,strpos($form_id[1],'"'));
//echo 'got form_id: '.$form_id[1].'<br />';
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'post_form_id='.$form_id[1].'&news_feed=1&message=Hi&connect="Send Request"');
curl_setopt($ch, CURLOPT_URL, $link);
$page = curl_exec($ch);
return $page;
}
?>
If anyone have any suggestions about how to earn some money out of this or any other scripts PM me i'm clueless but i have some coding skillz
Thanks,
kod
Last edited: