久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

PHP &Facebook: facebook-debug a URL using CURL and Fa

PHP amp; Facebook: facebook-debug a URL using CURL and Facebook debugger(PHP amp;Facebook: facebook-debug a URL using CURL and Facebook debugger)
本文介紹了PHP &Facebook: facebook-debug a URL using CURL and Facebook debugger的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

事實(shí):我運(yùn)行一個(gè)簡單的網(wǎng)站,其中包含文章、通過抓取第三方網(wǎng)站/博客等動(dòng)態(tài)獲取的文章(新文章每半小時(shí)左右到達(dá)我的網(wǎng)站)、文章我想在我的 facebook 頁面上發(fā)帖.每篇文章通常包括一張圖片、一個(gè)標(biāo)題和一些文字.

Facts: I run a simple website that contains articles, articles dynamically acquired by scraping third-party websites/blogs etc (new articles arrive to my website every half an hour or so), articles which I wish to post on my facebook page. Each article typically includes an image, a title and some text.

問題:我在 Facebook 上發(fā)布的大部分(幾乎所有)文章都沒有正確發(fā)布 - 缺少圖片.

Problem: Most (almost all) of the articles that I post on Facebook are not posted correctly - their images are missing.

低效解決方案:使用 Facebook 的調(diào)試器(這個(gè))我向它提交了一篇文章的 URL(來自我網(wǎng)站的 URL,而不是原始來源的 URL),然后 Facebook 掃描/抓取 URL 并正確提取所需的信息(圖像、標(biāo)題、文本等).執(zhí)行此操作后,文章可以正確發(fā)布到 Facebook 上 - 不會丟失圖片或任何內(nèi)容.

Inefficient Solution: Using Facebook's debugger (this one) I submit an article's URL to it (URL from my website, not the original source's URL) and Facebook then scans/scrapes the URL and correctly extracts the needed information (image, title, text etc). After this action, the article can be posted on Facebook correctly - no missing images or anything.

目標(biāo):我所追求的是一種創(chuàng)建過程的方法,該過程將向 Facebook 的調(diào)試器提交 URL,從而迫使 Facebook 掃描/抓取 URL,以便隨后可以正確發(fā)布.我相信我需要做的是創(chuàng)建一個(gè)包含 URL 的 HTML POST 請求并將其提交給 Facebook 的調(diào)試器.這是正確的方法嗎?如果是,因?yàn)槲乙郧皼]有使用 CURL 的經(jīng)驗(yàn),那么在 PHP 中使用 CURL 的正確方法是什么?

Goal: What I am after is a way to create a process which will submit a URL to Facebook's debugger, thus forcing Facebook to scan/scrape the URL so that it can then be posted correctly. I believe that what I need to do is to create an HTML POST request containing the URL and submit it to Facebook's debugger. Is this the correct way to go? And if yes, as I have no previous experience with CURL, what is the correct way to do it using CURL in PHP?

旁注:作為旁注,我應(yīng)該提到我的文章使用的是短 URL,盡管我認(rèn)為這不是問題的原因,因?yàn)榧词乖谖沂褂靡?guī)范的 URL.

Side Notes: As a side note, I should mention that I am using short URLs for my articles, although I do not think that this is the cause of the problem because the problem persists even when I use the canonical URLs.

此外,Open Graph 元標(biāo)記設(shè)置正確(og:image、og:description 等).

Also, the Open Graph meta tags are correctly set (og:image, og:description, etc).

推薦答案

您可以使用帶有 PHP-cURL 的 Facebook 圖形 API 調(diào)試圖形對象,方法是執(zhí)行 POST

You can debug a graph object using Facebook graph API with PHP-cURL, by doing a POST to

https://graph.facebook.com/v1.0/?id={Object_URL}&scrape=1

為了更簡單,我們可以將調(diào)試器包裝在一個(gè)函數(shù)中:

to make thing easier, we can wrap our debugger within a function:

function facebookDebugger($url) {

        $ch = curl_init();
              curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/v1.0/?id='. urlencode($url). '&scrape=1');
              curl_setopt($ch, CURLOPT_POST, 1);
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
              curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $r = curl_exec($ch);
        return $r;

}

雖然這會更新 &為傳遞的 URL 清除 Facebook 緩存,打印出每個(gè)鍵有點(diǎn)困難它的內(nèi)容并同時(shí)避免錯(cuò)誤,但是我建議使用 var_dump()print_r() 或 PHP-ref

though this will update & clear Facebook cache for the passed URL, it's a bit hard to print out each key & its content and avoid errors in the same time, however I recommended using var_dump() or print_r() OR PHP-ref

使用 PHP-ref

r( facebookDebugger('http://retrogramexplore.tumblr.com/') );

這篇關(guān)于PHP &Facebook: facebook-debug a URL using CURL and Facebook debugger的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個(gè)表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設(shè)置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數(shù)組自動(dòng)填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產(chǎn)生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 最新日韩精品 | 日韩中文字幕免费在线观看 | 毛片av免费在线观看 | 久久专区| 久久精品这里精品 | 一区二区视频在线观看 | 国产美女一区二区三区 | 青青久在线视频 | 欧美一级特黄aaa大片在线观看 | 日韩av在线一区二区 | 日韩91 | 婷婷一级片 | 大陆一级毛片免费视频观看 | 午夜视频导航 | 香蕉久久久 | 国产午夜精品视频 | 一级黄在线观看 | 欧美色性| 亚洲一区欧美一区 | 毛片免费看的 | 国产高清一区二区三区 | 日韩精品视频在线观看一区二区三区 | 国产亚洲一区二区在线观看 | 福利网站导航 | 伊人网站在线观看 | 国产精品一区二区三区在线 | 日本在线观看视频 | 欧美在线激情 | 亚洲成人黄色 | 2022精品国偷自产免费观看 | 亚洲人成网亚洲欧洲无码 | 久久婷婷av | 亚洲欧美日韩久久 | 黄色网址免费看 | 免费在线观看黄色av | 亚洲国产成人精品一区二区 | 午夜久久久久久久久久一区二区 | 日韩一区中文字幕 | 欧美mv日韩mv国产网站91进入 | 亚洲精品一区二区在线观看 | 中文字幕亚洲在线 |