articlai/articlai-laravel 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

articlai/articlai-laravel

最新稳定版本:v1.0.6

Composer 安装命令:

composer require articlai/articlai-laravel

包简介

Package to allow blog publishing in Laravel using Articlai

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A Laravel package that enables seamless integration with ArticlAI's Custom API connection type. This package provides secure API endpoints that allow ArticlAI to create, update, and delete blog posts in your Laravel application.

Installation

You can install the package via composer:

composer require articlai/articlai-laravel

You can publish and run the migrations with:

php artisan vendor:publish --tag="articlai-laravel-migrations"
php artisan vendor:publish --tag="medialibrary-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="articlai-laravel-config"

Configuration

After publishing the config file, update your .env file with your ArticlAI settings:

# Authentication Method (api_key, bearer_token, or basic_auth)
ARTICLAI_AUTH_METHOD=api_key
ARTICLAI_API_KEY=your-secret-api-key

API Endpoints

The package provides the following endpoints for ArticlAI integration:

Validation Endpoint

GET /api/articlai/validate

Returns platform information and validates the connection.

Content Management

POST /api/articlai/posts          # Create a new post
GET /api/articlai/posts/{id}      # Get a specific post
PUT /api/articlai/posts/{id}      # Update a post
DELETE /api/articlai/posts/{id}   # Delete a post

Banner Images

The package supports banner images through Spatie Media Library integration. When creating or updating posts, you can include banner image URLs:

{
  "title": "Blog Post Title",
  "content": "<p>Post content</p>",
  "banner_image": "https://example.com/image.jpg",
  "banner_original": "https://example.com/original.jpg"
}

The package will automatically download and store the images, creating multiple conversions:

  • thumbnail: 150x150px (cropped)
  • medium: 300x300px (cropped)
  • large: 800x600px (cropped)
  • original: Original image

Usage

Using the Service Class

use Articlai\Articlai\Articlai;

$articlai = app(Articlai::class);

// Create a post with banner image
$post = $articlai->createPost([
    'title' => 'My Blog Post',
    'content' => '<p>This is the content</p>',
    'excerpt' => 'Post excerpt',
    'status' => 'published',
    'banner_image' => 'https://example.com/banner.jpg'
]);

// Update a post
$updatedPost = $articlai->updatePost($post->id, [
    'title' => 'Updated Title'
]);

// Get posts
$posts = $articlai->getPosts(['status' => 'published']);

Using the Facade

use Articlai\Articlai\Facades\Articlai;

$post = Articlai::createPost([
    'title' => 'My Blog Post',
    'content' => '<p>This is the content</p>'
]);

Using the Model Directly

use Articlai\Articlai\Models\ArticlaiPost;

$post = ArticlaiPost::create([
    'title' => 'My Blog Post',
    'content' => '<p>This is the content</p>',
    'status' => 'published'
]);

// Get published posts
$publishedPosts = ArticlaiPost::published()->get();

// Access banner images
$post = ArticlaiPost::find(1);
echo $post->banner_image;      // Large version URL
echo $post->banner_thumbnail;  // Thumbnail URL
echo $post->banner_medium;     // Medium URL
echo $post->banner_large;      // Large URL
echo $post->banner_original;   // Original URL

Command Line Interface

Check the package status and view recent posts:

php artisan articlai:status --posts=10

Testing

composer test

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-21