2016-06-20 9 views
0

一致していない:Facebookのインスタント記事 - CONTENT私は<a href="https://github.com/facebook/facebook-instant-articles-sdk-php" rel="nofollow">Facebook Instant Articles PHP SDK</a>によって試験品を公開しようとしている

$the_html = '<!doctype html> 
<html lang="en" prefix="op: http://media.facebook.com/op#"> 
<head> 
    <meta charset="utf-8"> 
    <meta property="op:markup_version" content="v1.0"> 
    <link rel="canonical" href="http://myarticle"> 
    <meta property="fb:article_style" content="default"> 
</head> 
<body> 
    <article> 
    <header> 
     <h1> test title</h1> 
     <h2> test subtitle </h2> 

     <time class="op-published" dateTime="2016-06-20T08:00">June 17th 2016, 8:00 AM</time> 
     <time class="op-modified" dateTime="2016-06-20T08:00">June 17th 2016, 8:00 AM</time> 

     <p> Test test test </p> 
    </header> 
    </article> 
</body> 
</html>'; 

$fb = Client::create(
    'APP_ID' 
    'APP_SECRET', 
    'ACCESS_TOKEN', 
    'PAGE_ID', 
    true //development env 
); 

$instant_article = InstantArticle::create(); 
$transformer = new Transformer(); 
libxml_use_internal_errors(true); 
$document = new \DOMDocument(); 
$document->loadHTML($the_html); 
libxml_use_internal_errors(false); 

$transformer->transform($instant_article, $document); 

$fb->importArticle($instant_article, true); 

私はこのメッセージを取得しています:

DEBUGを - ======= ==================== DEBUG - ===================== DEBUG - コンテキストクラス:Facebook \ InstantArticles \ Elements \ InstantArticle DEBUG - ノード名: htmlデバッグ - コンテンツが一致しません:

Graph API ExplorerのインスタントアーティクルAPIを使用して記事を公開できましたが、PHPで動作させることはできません。

ご協力いただければ幸いです。

答えて

2

ルールを含むファイルを追加して読み込む必要があります。 File example

$rules = file_get_contents("instantArticlesModule/simple-rules.json", true); 
$transformer = new Transformer(); 
$transformer->loadRules($rules); 
+0

ご協力いただきありがとうございます。 Spasibo ^^ – whitesiroi

関連する問題