DEV Community

Cover image for Get recent blog posts from popular blogging platforms with PHP
Ariful Alam
Ariful Alam

Posted on • Edited on

2 1

Get recent blog posts from popular blogging platforms with PHP

PHP Blog Client is a PHP package to get recent blog posts from popular blogging platforms by just providing your username and showcase them on your portfolio or website.

Currently available platforms:

  • Dev
  • Medium

GitHub logo arifszn / php-blog-client

PHP client to get recent blog posts from popular blogging platforms.


PHP client to get recent blog posts from popular blogging platforms

Packagist · Report Bug · Request Feature


Get recent blog posts from popular blogging platforms by just providing your username and showcase them on your portfolio or website.

JavaScript version: blog.js

Installation

Install via composer

composer require arifszn/blog-client
Enter fullscreen mode Exit fullscreen mode

Usage

  • getDevPost(): Get 10 recent posts from dev.

    use Arifszn\Blog\Client;
    
    $client = new Client();
    $result = $client->getDevPost('yourusername');
    Enter fullscreen mode Exit fullscreen mode
  • getMediumPost(): Get 10 recent posts from medium.

    use Arifszn\Blog\Client;
    
    $client = new Client();
    $result = $client->getMediumPost('yourusername');
    Enter fullscreen mode Exit fullscreen mode

Sample Response

array:2 [▼
  0 => array:6 [▼
    "title" => "Why Enhancing Virtual Reality is Important"
    "description" => "Virtual reality is seen
Enter fullscreen mode Exit fullscreen mode

Step 1

To get started, install via composer.

composer require arifszn/blog-client
Enter fullscreen mode Exit fullscreen mode

Step 2

Import it.

use Arifszn\Blog\Client;
Enter fullscreen mode Exit fullscreen mode

Step 3

Use it.

$client = new Client();
$devPosts = $client->getDevPost('yourusername');
$mediumPosts = $client->getMediumPost('yourusername');
Enter fullscreen mode Exit fullscreen mode

It will return 10 most recent posts. Here is a sample response:

array:2 [
  0 => array:6 [
    "title" => "Why Enhancing Virtual Reality is Important",
    "description" => "Virtual reality is seen as a “fun” technology to some without much...",
    "thumbnail" => "https://cdn-images-1.medium.com/max/2600/0*kz30LOdXT8CyOymh",
    "link" => "https://medium.com/p/ac19dd21c728",
    "categories" => array:5 [
      "vr",
      "technology",
      "virtual-reality",
      "engineering",
      "artificial-intelligence"
    ],
    "publishedAt" => "2020-11-08 18:43:34"
  ],
  1 => array:6 [
    "title" => "How to Get Started With Data Science: a Brief Guide",
    "description" => "You’ve heard about data science and machine learning, and you want to get started. Maybe you hear...",
    "thumbnail" => "https://cdn-images-1.medium.com/max/2600/0*Ah0vLtsvxqUvRWuS",
    "link" => "https://medium.com/p/88ec244f2fee",
    "categories" => array:3 [
      "beginner-coding",
      "data-science-training",
      "machine-learning-course"
    ],
    "publishedAt" => "2020-26-07 22:55:26"
  ]
]
Enter fullscreen mode Exit fullscreen mode

Now, showcase them on your website like this example.
NPM package is also available here.

Source Code
Packagist

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (2)

Collapse
 
jnv profile image
Jan Vlnas

I am curious. Why don't you use the RSS feeds directly with, for example, SimplePie or SimpleXML, instead of running them through a third party service for conversion to JSON? 🤔

Collapse
 
arifszn profile image
Ariful Alam

Actually, the php package is a conversion of my JS package github.com/arifszn/blog.js. In the JS package, didn't want to install additional library and used the third party service.

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay