amsaid/world-news-api 问题修复 & 功能扩展

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

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

amsaid/world-news-api

最新稳定版本:v0.1.1

Composer 安装命令:

composer require amsaid/world-news-api

包简介

Laravel client for world news api

README 文档

README

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

Support us

If you like this package, consider supporting us by donating to support our development. Your support is greatly appreciated! 🙏

Buy Me A Coffee

Installation

You can install the package via composer:

composer require amsaid/world-news-api

You can publish the config file and the service provider with:

php artisan world-news-api:install

This is the contents of the published config file:

return [
    'apikey' => env('NEWS_API_KEY', 'your-api-key'),
];

Usage

use Amsaid\WorldNewsApi\Facades\NewsApi;

$news = NewsApi::search(query: 'Messi', countries: 'us', language: 'en'); // returns a collection of news items
$newsItem = $news->first(); // returns a single news item collection

// All news items are Laravel collections
$newsItem->toJson(); /* returns
{
    "summary": "Joan Monfort never believed in fate...",
    "image": "https://a.espncdn.com/photo/2024/0710/r1356881_1296x729_16-9.jpg",
    "sentiment": -0.456,
    "author": "Sid Lowe",
    "language": "en",
    "video": null,
    "title": "Photographer didn't believe in destiny...",
    "url": "https://www.espn.com/soccer/story/_/id/4088...",
    "source_country": "US",
    "id": 254279758,
    "text": "...",
    "category": null,
    "publish_date": "2024-08-16 18:40:10",
    "authors": [
      "Sid Lowe"
    ]
  }
*/

// Access the summary of the first news item
$newsItem->get('summary'); // 'Joan Monfort never believed in fate...'

// Access the author of the first news item
$newsItem->get('author'); // 'Sid Lowe'

// Loop through each news item
foreach ($news as $item) {
    // Access the title of each news item
    echo $item->get('title');
}

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固