Facebook Instant Articles Строка отладки PHP SDK

Я пытаюсь преобразовать свою html-страницу в формат мгновенных статей Facebook.

Я продолжаю появляться на экране

"ОТЛАДКА - =========================== ОТЛАДКА -"

Когда я вызываю "$transformer->transformString" или "$transformer->transform($header, $document);"

Почему так? Я ничего не повторяю.

(Это не сайт wordpress)

$header =
    Header::create()
      ->withPublishTime(
        Time::create( Time::PUBLISHED )->withDatetime(
            \DateTime::createFromFormat(
              'j-M-Y G:i:s',
              date('j-M-Y G:i:s', strtotime($published_date))
            ))
      )
      ->withModifyTime(
        Time::create( Time::MODIFIED )->withDatetime(
            \DateTime::createFromFormat(
              'j-M-Y G:i:s',
              date('j-M-Y G:i:s', strtotime($last_modified_date))
            ))
      );
// Loads the rules configuration file

$rules_file_content = file_get_contents("rules-configuration.json", true); 
// Load html content from a file. 
//$content = file_get_contents("sample-html.html", true);
$content = get_the_content();

// Create a transformer object and load the rules
$transformer = new Transformer();
$transformer->loadRules($rules_file_content);
$document = new DOMDocument();
libxml_use_internal_errors(true);
$document->loadHTML( '<?xml encoding="' . $charset . '" ?><h1>' . $title . '</h1>' );
libxml_use_internal_errors(false);

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

if($subtitle) {
  $header->withSubTitle ($subtitle);
}

if ( $kicker ) {
  $header->withKicker( $kicker );
}
    define( 'IA_PLUGIN_VERSION', '4.0.5' );

$instant_article =
      InstantArticle::create()
        ->withCanonicalUrl( $cannonical_link )
        ->withHeader( $header )
        ->addMetaProperty( 'op:generator:application', 'facebook-instant-articles' )
        ->addMetaProperty( 'op:generator:application:version', IA_PLUGIN_VERSION );
$instant_article->withStyle( 'default' );
$transformer->transformString( $instant_article, $content, $charset );
// Instantiate an API client
$client = Client::create(
  $APP_ID,
  $APP_SECRET,
  $ACCESS_TOKEN,
  $PAGE_ID,
  $is_development 
);
// Import the article
try {
    $client->importArticle($instant_article, $is_published);
} catch (Exception $e) {
    echo 'Could not import the article: '.$e->getMessage();
}

person boaz    schedule 13.11.2017    source источник
comment
github.com/facebook/facebook-instant-articles -sdk-php/   -  person CBroe    schedule 13.11.2017
comment
@CBroe Как я могу обойти это?   -  person boaz    schedule 13.11.2017
comment
В режиме разработки?   -  person Leopold Spanovic    schedule 13.11.2017
comment
@LeopoldSpanovic Как я могу проверить?   -  person boaz    schedule 13.11.2017


Ответы (1)


Добавьте эти строки :)

\Logger::configure(
[
    'rootLogger' => [
        'appenders' => ['facebook-instantarticles-traverser']
    ],
    'appenders' => [
        'facebook-instantarticles-traverser' => [
            'class' => 'LoggerAppenderConsole',
            'threshold' => 'INFO',
            'layout' => [
                'class' => 'LoggerLayoutSimple'
            ]
        ]
    ]
]);

Источник: https://github.com/facebook/facebook-instant-articles-sdk-extensions-in-php/blob/master/examples/quiet_logger.php

person Flappy    schedule 25.11.2017