0

I have been looking for a script in php to Curl the facebook linter URL so it forces Facebook to scrape my page again to update my open graph data.

2 Answers 2

4

according to facebook's documentation you can simply do it by using the linter api and passing scrape=true parameter:

curl -X POST \
    -F "id={object-url OR object-id}" \
    -F "scrape=true" \
    "https://graph.facebook.com"

or by using php:

 $access_token="APP_ID|APP_SECRET"; //replace with your app details
 $params = array("id"=>'/*YOU PAGE URL*/',"scrape"=>"true","access_token"=>$access_token);
 $ch = curl_init("https://graph.facebook.com");
 curl_setopt_array($ch, array(
      CURLOPT_RETURNTRANSFER=>true,
      CURLOPT_SSL_VERIFYHOST=>false,
      CURLOPT_SSL_VERIFYPEER=>false,
      CURLOPT_POST=>true,
      CURLOPT_POSTFIELDS=>$params
 ));
 $result = curl_exec($ch);

as described here

Sign up to request clarification or add additional context in comments.

Comments

0

here is the script I found and corrected a bit with help from stackoverflow !

$url = "http://developers.facebook.com/tools/debug/og/object?q=http://www.example.com";
$useragent = "Opera/9.80 (X11; Linux x86_64; U; en) Presto/2.10.229 Version/11.60";

if ( $ch = curl_init( $url ) )
{
    curl_setopt( $ch , CURLOPT_HEADER , 0 );
    curl_setopt( $ch , CURLOPT_RETURNTRANSFER , true );
    curl_setopt( $ch , CURLOPT_USERAGENT , $useragent );
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

    $str_response = curl_exec( $ch );

    if( curl_errno( $ch ) != 0 )
    {
        $message = 'Girl of the day - cURL exec error: ' . $ch;

        error_log( $message );
    }

    curl_close( $ch );
}
else
{
    $message = 'Girl of the day - cURL init with url: ' . $url . ' failed';

    error_log( $message );
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.