 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
07-27-2011, 05:03 PM
|
#1 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Fetching facebook-friends
Whoa, long time I was here!
And long time I've actually done any PHP coding.
In any case, I've seen these apps on Facebook that lets you see who defriended you. Unfortunately these apps were removed, I'm guessing Facebook doesn't want you to keep track of who's defriending you since it's something "negative" and Facebook's all about positive.. right?
Anyways.
In order to use the Facebook SDK-PHP API I need an APP ID .. I don't want to register an application for something that I will solely use on my local machine. So how would I go about fetching everyone from my friends-list?
Is there a "guest" APP ID I can use from my local machine? I was thinking about somehow fetching the HTML content of the friends-page and (again) "somehow" strip everything and only save the friends name, userid, etc.
Any suggestions or ideas on how to proceed to be able to create this?
__________________
|
|
|
|
07-27-2011, 10:00 PM
|
#2 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
Welcome Back Tanax,
The simplest way that, my brain can come up with at this
moment is use curl or something like that & as you said get
the friend list & then i would take the names and generate
a id for, individual names, save it up & then you can count
the names by id and search etc,
then compare by name id etc and let's say id
32 is not on updated list run check on name for
id 32 and then print out lets say id 32 = Jane doe,
well Jane doe has defriended you.
(because she ain't on the list anymore).
-cf
|
|
|
|
07-27-2011, 10:23 PM
|
#3 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by codefreek
Welcome Back Tanax,
The simplest way that, my brain can come up with at this
moment is use curl or something like that & as you said get
the friend list & then i would take the names and generate
a id for, individual names, save it up & then you can count
the names by id and search etc,
then compare by name id etc and let's say id
32 is not on updated list run check on name for
id 32 and then print out lets say id 32 = Jane doe,
well Jane doe has defriended you.
(because she ain't on the list anymore).
-cf
|
Hey Codefreek and thanks for the reply!
Yes thank you, I already have a system to store and manage the actual comparing of the friendslist. Regarding the id, I don't have to generate one, they already have a facebook id, for instance mine is: "562191521" -> http://www.facebook.com/profile.php?id=562191521
The thing I need help with is how to actually fetch the friends. How exactly would you suggest using cURL? :)
__________________
|
|
|
|
07-27-2011, 10:26 PM
|
#4 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Or rather, the cURL part wouldn't be that hard. I just googled it and while I'll still have to read up on it, it looks fairly straight-forward.
However, how would I do the actual stripping-part to get only the friends?
I suck at regex :/
__________________
|
|
|
|
07-28-2011, 12:26 AM
|
#5 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Okay, so I've managed to come a bit on the way.
First snag I hit was that when using cURL from localhost it didn't recognize that I was logged in and returned a loginpage. I've managed to get it working and logging in aswell as redirecting to the friendslist(Account->Edit Friends): http://www.facebook.com/friends/?everyone&ref=tn
The problem now is that it doesn't list everyone. It only lists "Recently Interacted". How to I get cURL to send so that it selects "All friends" from the dropdown-list?
The regex is still an issue.
I got this so far:
php Code:
preg_match_all( '@profile\.php\?id\=(.*?)\">(.*?)<@i', $line, $matches );
$line is result from cURL.
However it brings back some weird results. Perhaps someone can doublecheck the regex for me?
__________________
|
|
|
|
07-28-2011, 03:03 PM
|
#6 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Okay, I made some changes and it works GREAT now to fetch the names and only the names of your friends. Prints them out in an easy way. Still have to make the database and that.. but for now it seems like the matching of links and all that fuzz is complete.
HOWEVER!
I still need some help with cURL to get to the page I want.
Like I explained in my previous post, I need to somehow via cURL select an item from a dropdown-list. How would I do that?
And then, after I've selected that, I need to be able to go to the "next" page since the friends-list is paginated. How would I do that?
Here's the script so far:
PHP Code:
<?php
include_once('simple_html_dom.php');
$user_id = ''; $user_email = ""; $user_pass = "";
$fp = fopen("example.html", "w"); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://login.facebook.com/login.php?&next=http://www.facebook.com/friends/?everyone&ref=tn'); curl_setopt($ch, CURLOPT_POSTFIELDS,'email='.urlencode($user_email).'&pass='.urlencode($user_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, "cookie.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FILE, $fp); 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);
// So we can view the facebook-page include('example.html');
$html = file_get_html("example.html"); $count = 0; $found = 0;
foreach( $html->find('a') as $link ) { $count++; if( strpos( $link, 'profile.php?id=' ) && !strpos( $link, $user_id ) && !strpos( $link->innertext, 'img' ) ) { $found++; echo 'Link #' . $found . ': ' . $link->innertext; echo '<br />'; } }
echo $count . ' links found where ' . $found . ' links matched profile-links';
To test it, remember to:
1) Download simple_html_dom from http://simplehtmldom.sourceforge.net/
2) Create an empty example.html
3) Create an empty cookie.txt
__________________
|
|
|
|
07-28-2011, 04:08 PM
|
#7 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
Quote:
|
And then, after I've selected that, I need to be able to go to the "next" page since the friends-list is paginated. How would I do that?
|
you need to check how to url changes when you change a page,
and then tell curl the new string for new page.
if you know what i mean
check this
check this also.
|
|
|
|
07-28-2011, 08:31 PM
|
#8 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by codefreek
you need to check how to url changes when you change a page,
and then tell curl the new string for new page.
if you know what i mean
check this
check this also.
|
Unfortunately it doesn't change at all. I'm suspecting they are either using POST to change the page or JS/AJAX to load another page.
Tried searching for how cURL handles javascript but no luck.
__________________
|
|
|
|
09-02-2011, 11:24 AM
|
#9 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
I actually solved this by using the mobile site instead. It uses no(or less) javascript so it's easier to get the friends from there. Script is fully functional and I've loaded all my friends into a local database.
__________________
|
|
|
|
10-18-2012, 09:55 AM
|
#10 (permalink)
|
|
The Addict
Join Date: Oct 2012
Posts: 244
Thanks: 0
|
Some conservatives have Coach Factory Outlet pushed that critique further, saying that Mr. Obama’s policies are too costly, often assist the wrong people Louis Vuitton Belts and could have the paradoxical effect of driving up college costs. The dispute turns not just on different Coach Factory Outlet assessments of how policies play out, but on differing philosophical views about the role of government. During Gucci Belts his time in office, Mr. Obama has sharply increased aid to low- and middle-income students, notably through the Pell Grant Coach Factory Outlet program, which grew from $14.6 billion given to 6 million students in 2008, to nearly $40 billion for Coach Factory Outlet almost 10 million students this year. His administration also made it easier to request aid, shortening the Coach Factory Online complex federal application and allowing people to transfer their financial information electronically from the Internal Coach Outlet Online Revenue Service database. But while many education experts laud his efforts, analysts of varying political Coach Outlet Online stripes have also questioned how much impact some of the president’s policies will have, noting that the prices Coach Online Outlet charged by colleges, and student borrowing, continue to climb.But behind the headlines about soaring costs, the Coach Factory Outlet Online reality is more complex and wildly uneven, because a growing number of students receive Coach Outlet Online financial aid, and only relatively high-income families pay those fast-rising sticker prices. Adjusted for Coach Factory Online inflation, the College Board calculates, the average net price changed little over the last decade at private Coach Factory Outlet schools, and rose only modestly at public ones.Defending federal spending, Arne Duncan, the secretary of Hermes Belts education, said that for more than 30 years, college prices had risen even when federal aid had not, leading him to believe Coach Factory Online there was zero correlation.
|
|
|
|
10-22-2012, 08:29 AM
|
#11 (permalink)
|
|
The Addict
Join Date: Oct 2012
Posts: 244
Thanks: 0
|
Coach Outlet
You’ve relatively Coach Outlet recently arrived in New Delhi after living in two of Asia’s other great cities, Coach Outlet Store Online Tokyo and Hong Kong, for several years. Do these cities feel like they’re part of the same continent? Yes, and no. In terms Coach Factory Onlineof infrastructure, they couldn’t be more different. Getting regular Coach Outlet power and water at my house in New Delhi is never a sure thing, even though Coach Purse Outlet OnlineI’m paying the same rent that I paid in Tokyo and almost the same electricity prices. Both Hong Kong and Tokyo are also crowded places, Coach Factory Outlet Online but both cities are incredibly well planned and efficiently run. Efficient is not a word I would use to describe my Coach Bags Outlet Onlineday-to-day life in New Delhi. On the other hand, one thing that I think Hong Kong and New Delhi have in common is Coach Handbags Outlet a shared sense of optimism — a feeling that the best is yet to come. That’s definitely not the feeling you get in Tokyo, Coach Outlet Online or in the U.S. when I go home. It’s a big part of what I find addictive about living and working in this part of the world. You feel like you’re watching the future unfold.
|
|
|
|
01-29-2013, 12:21 PM
|
#12 (permalink)
|
|
The Addict
Join Date: Oct 2012
Posts: 244
Thanks: 0
|
Organizers said Coach Outlet Online was opportune because the battle’s 150-year anniversary is in December, and Fredericksburg Coach Factory Outlet has been preparing to mark the sesquicentennial. in the new agreement is that Coach Outlet Online revolutionary councils from 14 Syrian provinces now each have a representative, though not all live Coach Online Outlet in Syria. The hope is that will bind the coalition to those inside the country. Perhaps Coach Bags Outlet the most important body the new group is expected to form is a Revolutionary Military Council Coach Factory Online to oversee the splintered fighting organizations and to funnel both lethal and nonlethal Coach Factory Outlet military aid to the rebels. It should unite units of the Free Syrian Army, various militias Coach Outlet Store Online and brigades in each city and large groups of defectors. Before the ink was even dry on the Coach Outlet Store final draft, negotiators hoped that it would bring them the antiaircraft missiles they crave to Coach Factory Stores take on the Syrian Air Force. The United States and Britain have offered only Coach Handbags Outlet nonmilitary aid to the uprising. A similar attempt by the Syrian National Council to Coach Factory Store supervise the military never jelled. Organizers said funding was too haphazard. Eventually foreign Coach Factory Online governments like Qatar and Saudi Arabia, which are financing and arming the rebels, found Coach Factory Online their own favorite factions to deal with. Foreign leaders notably including Secretary of State Coach Outlet Hillary Rodham Clinton urged this unification largely so they could coordinate their Coach Factory Outlet efforts and aid through a group of technocrats. Once it receives international recognition, the Coach Outlet Store Online coalition is supposed to establish a temporary Coach Outlet Online military never jelled.
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|