1

I am using AppleNewsAPI to create apple news documents and submit them to apple news. Even looking at the API doc I can't understand how to grammatically apply the style. this is what I have done so far:

$obj = new Document(uniqid(), 'my headline', 'en', new Layout(7, 1024));
$obj->addComponent(new Body('article body'))
->addComponent(new Document\Components\Title('my headline'))
->addComponent(new Document\Components\Caption('my caption'))
[...]
->addComponentTextStyle('default', new ComponentTextStyle());

and this produce a valid json file for apple. How can I pass some style information using this library?

thanks

1 Answer 1

0

This is how you add styles and layouts:

$title_id = uniqid();
$title = new ChapterThree\AppleNewsAPI\Document\Components\Title( 'Your title', $title_id );

// Component style (Text)
$text_style = new ChapterThree\AppleNewsAPI\Document\Styles\ComponentTextStyle();
$text_style->setTextAlignment( 'left' );
$text_style->setTextTransform( 'none' );
$text_style->setFontName( 'HelveticaNeue-CondensedBold' );
$text_style->setLineHeight( 52 );
$text_style->setFontSize( 48 );
$text_style->setTextColor( '#000000' );

// Layout
$layout = new ChapterThree\AppleNewsAPI\Document\Layouts\ComponentLayout;();
$layout->setMargin( new ChapterThree\AppleNewsAPI\Document\Margin( 8, 5 ) );
$title->setTextStyle( $title_id . '-style' );
$title->setLayout( $title_id . '-layout' );
$document->addComponentTextStyle( $title_id . '-style', $text_style );
$document->addComponentLayout( $title_id . '-layout', $layout );

// Add to the main document object.
$document->addComponent($title);

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.