How to extract public profile information from Facebook based on name using curl utility

1.1k views Asked by At

I am trying to extract all public profile information i.e. name,birthday,location,gender, hometown,education, hobby using curl utility. I am using proper access token but I am only able to extract id,name,gender based on any name search using curl utility.

Can anybody help me on what exact steps to follow to extract all public information shared by a person in Facebook using curl utility.

An early reply is highly appreciated.

1

There are 1 answers

0
spyder On

Set the URL first:

$url = https://graph.facebook.com/USER_ID/?fields=name,email,username,birthday

Now, call this function curlify

$contents = curlify($url);

This is the function:

function curlify($url)
{
    $c = curl_init();
    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($c, CURLOPT_URL, $url);
    $contents = curl_exec($c);
    $err  = curl_getinfo($c,CURLINFO_HTTP_CODE);
    curl_close($c);

    return $contents;
}

It will return the data in JSON format