2

I'm new to programming and I don't know how to set up a normal PHP extension like cURL. I've installed PEAR packages before but that's all. I think what I'm trying to do is very simple - just getting Facebook's linter to lint my URL upon a page reload on my site. The code Facebook suggests is simply this:

curl https://developers.facebook.com/tools/lint/?url={YOUR_URL}&format=json

Is this supposed to just work if I throw it inside of <?php ?> tags, or is Facebook not assuming that I use PHP? Let's say my site's URL is http://www.example.com - how should this code look in a PHP file? And how am I supposed to install the cURL library? Sorry for being clueless! ;)

tylerl
  • 1,160
  • 1
  • 19
  • 41

1 Answers1

3

This should help you installing cURL: How to install PHP/CURL?

You can use a code similar to this to get the page:

<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://developers.facebook.com/tools/lint/?url=" . urlencode ( 'http://www.example.com/' ) . "&format=json");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$data = curl_exec($ch);

curl_close($ch);

echo $data;
?>
Community
  • 1
  • 1
Jeroen
  • 13,056
  • 4
  • 42
  • 63
  • So what does work? I seem to remember reading that they automatically check for changes every 24 hours, as well as any time an admin likes/comments on the page. In that case I'm probably okay but it probably wouldn't hurt to use cURL? I never actually implemented this code because I don't know how to, but could you tell how it's supposed to be done now? Thanks :) – tylerl Sep 22 '11 at 18:36