PHP code example of abr4xas / publish-to-dev-to

1. Go to this page and download the library: Download abr4xas/publish-to-dev-to library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

abr4xas / publish-to-dev-to example snippets



icleToPost = [
    'article' => [
        'title' => 'Hello, World! From the dev.to API',
        'body_markdown' => 'This my markdown body text',
        'description' => 'Hello, World! From the dev.to API <3',
        'cover_image' => 'https://i.pinimg.com/originals/97/90/12/979012800b47e3bb871cae4009333e08.jpg',
        'tags' => [
            'hello',
            'world'
        ],
    ],
];

try {

    $devTo = (new \Abr4xas\PublishToDevTo\PublishTo('<YOUR_API_KEY>'))
        ->devToMyArticle($articleToPost);

} catch (\Abr4xas\PublishToDevTo\Exceptions\GenericException $e) {
    //
} catch (\GuzzleHttp\Exception\ClientException $e) {
    //
}