public function DrupalClient::importArticle in Facebook Instant Articles 7
Same name and namespace in other branches
- 7.2 modules/fb_instant_articles_api/src/DrupalClient.php \Drupal\fb_instant_articles_api\DrupalClient::importArticle()
Additionally try to catch an attempted import call.
@todo Revisit this try/catch wrapper if the API gives an API option to see if the page has passed review. This may in fact be the best way, but that is still in discussion by the Facebook team.
File
- modules/
fb_instant_articles_api/ src/ DrupalClient.php, line 53 - Contains \Drupal\fb_instant_articles_api\DrupalClient.
Class
- DrupalClient
- Encapsulates any Drupal-specific logic when using the Client.
Namespace
Drupal\fb_instant_articles_apiCode
public function importArticle($article, $takeLive = FALSE) {
try {
parent::importArticle($article, $takeLive);
} catch (FacebookResponseException $e) {
// If this was an authorization exception and the error code indicates
// that the page has not yet passed review, try posting the article
// unpublished. Only try again if the article was intended to be
// published, so we don't try to post unpublished twice.
if ($e
->getCode() === self::FB_INSTANT_ARTICLES_ERROR_CODE_PERMISSION && $e
->getSubErrorCode() === self::FB_INSTANT_ARTICLES_ERROR_CODE_PAGE_NOT_APPROVED && $takeLive) {
parent::importArticle($article, FALSE);
}
}
}