facebookarchive / facebook-instant-articles-sdk-php

The Facebook Instant Articles SDK for PHP provides a native interface for creating and publishing Instant Articles.
https://instantarticles.fb.com/
Other
232 stars 148 forks source link

@meta "fb:op-recirculation-ads" were removed when Transformer? #271

Closed tungvn closed 6 years ago

tungvn commented 7 years ago
  1. Prepare input html and make sure html contains meta tag "fb:op-recirculation-ads", like this:
<meta property="fb:op-recirculation-ads" content="placement_id=xxxxxxxxx">
  1. Load rules and load input html by Transformer
$rules = file_get_contents(__DIR__ . "/facebook-sdk-php/vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Parser/instant-articles-rules.json", true);
// Create the transformer and loads the rules
$transformer = new Facebook\InstantArticles\Transformer\Transformer();
$transformer->loadRules($rules);

libxml_use_internal_errors(true);
$document = new \DOMDocument();
$v_news_html = mb_convert_encoding($v_news_html, 'HTML-ENTITIES', "UTF-8");
$document->loadHTML($v_news_html);
libxml_use_internal_errors(false);

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

I added some custom rules for this meta tag, but anything change

{
    rules: [...
        ,{
                "class" : "PassThroughRule",
                "selector" : "head meta"
            } ] }
  1. Import Instant Article
$__fbClient->importArticle($instant_article);

How to add that meta tag?

tungvn commented 7 years ago

I have make a PR to fix this issue