Tallboy
Tallboy

Reputation: 13467

Facebook Debug Tool via cURL

I'm trying to use the Facebook Linter programmatically, so that when I update a post it automatically pings FB to pull the new open graph information.

All the solutions I'm finding online don't seem to work anymore though, and are all old.

Is there a way to do this?

This is what I have so far which doesn't work

$params = array(                                                            
  'id' => $url,                                                             
  'scrape' => 'true',                                                       
  'access_token' => '12345|987654321'      
);                                                                          

$ch = curl_init("https://graph.facebook.com?" . http_build_query($params)); 
curl_setopt_array($ch, array(                                               
  CURLOPT_HEADER => 0,                                                      
  CURLOPT_RETURNTRANSFER => true,                                           
  CURLOPT_SSL_VERIFYHOST => false,                                          
  CURLOPT_SSL_VERIFYPEER => false,                                          
));                                                                         

$result = curl_exec($ch); 

Upvotes: 0

Views: 892

Answers (1)

Niraj Shah
Niraj Shah

Reputation: 15457

Add CURLOPT_POST to your CURL request so that the data is POSTed to the Graph API:

curl_setopt_array($ch, array(                                               
  CURLOPT_HEADER => 0,
  CURLOPT_POST => 1,
  CURLOPT_RETURNTRANSFER => true,                                           
  CURLOPT_SSL_VERIFYHOST => false,                                          
  CURLOPT_SSL_VERIFYPEER => false,                                          
));

See the documentation here.

Upvotes: 1

Related Questions