-3

I am building Facebook profile picture scraper and using Phasher class to convert scraped pictures to Hexadecimal values and store it inside the database to compare it for similar pictures, Now I was using this http request to fetch for the pictures and it was working very well till the latest update for the Graph API v2.5

graph.facebook.com/'.$fid.'/picture?width=378&height=378

Or

graph.facebook.com/'.$fid.'/picture?type=large

you can change '.$fid.' to user id example for Mark account:

graph.facebook.com/4/picture?width=378&height=378

As you can see, It gave me Mark Zuckerberg's account picture.

It's not working now, I made a simple search I noticed that they changed the API in v2.5 to use access token so I created an application to give me App id and App secret to use it in the access_token=

as you can see in this line: graph.facebook.com/[ID]/picture?width=378&height=378&access_token=

Now when I use access token it's not working it was before giving me the scraped pictures inside avatar folder and hashed values inside database now it gives me 0 bytes pictures and it's blank.(Strange thing when I started the scraper it's scraped 184 and 249 profile pictures of the 300 scraped pictures)

I need to know why this happened ?

You can look at the full code on my Github account: github.com/jadolyo/FBpp

Any suggestions are welcomed too, Thanks.

Jadolyo
  • 39
  • 8
  • You should not be “scraping” random user’s profile pictures in any case. You should only access the pictures of people that are using your app. – CBroe Oct 12 '15 at 18:07
  • I am making inverse image search tool for all Facebook profile pictures to search for similar profile pictures. please look at my Github account: http://github.com/jadolyo/FBpp – Jadolyo Oct 12 '15 at 18:16
  • You should read their ToS and Platform Policy. The first one forbids scraping without Facebook’s explicit prior written permission – and even if you were to use an app for this, Policy 3.11 still says, _“Don't put Facebook data in a search engine or directory, or include web search functionality on Facebook.”_ – CBroe Oct 12 '15 at 18:26
  • Thank you for your advice I appreciate it I am writing this for fun and to sharpen my skills in programming nothing more, It's actually a challenge to make it :) – Jadolyo Oct 12 '15 at 18:35
  • 1
    You probably want to read: https://www.facebook.com/apps/site_scraping_tos_terms.php – WizKid Oct 12 '15 at 20:27
  • Thank you WizKid for sharing that link, I don't have the resources to scrap that amount of data actually but the scraper for educational purposes only, It's nice that some software engineer working in Facebook answered me :D – Jadolyo Oct 12 '15 at 20:36
  • Educational or not, the TOS apply in all cases @Jadolyo – Tobi Oct 13 '15 at 07:19
  • Then come and put me in jail Tobi because I am learning and coding an idea, What about to kill me better...... – Jadolyo Oct 13 '15 at 22:35

1 Answers1

0

http://php.net/manual/en/migration56.openssl.php

An official document describing the changes made to open ssl in PHP 5.6 From here I learned of one more parameter I should have set to false: "verify_peer_name"=>false

So my working code looks like this:

$arrContextOptions=array(
    "ssl"=>array(
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ),
);

$img = file_get_contents('https://graph.facebook.com/'.$fid.'/picture?width=378&height=378', false, stream_context_create($arrContextOptions));
Jadolyo
  • 39
  • 8