簡體   English   中英

PHP腳本來卷曲Facebook Linter Url

[英]PHP script to Curl Facebook Linter Url

我一直在尋找php中的腳本來卷曲Facebook linter URL,因此它迫使Facebook再次刮我的頁面以更新我的打開圖形數據。

根據facebook的文檔,您可以簡單地通過使用linter api並傳遞scrape=true參數來做到這一點:

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

或使用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);

描述在這里

這是我在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 );
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM