gsmpopovic/medium-api 问题修复 & 功能扩展

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

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

gsmpopovic/medium-api

最新稳定版本:v1.0.0

Composer 安装命令:

composer require gsmpopovic/medium-api

包简介

A simple PHP SDK to interact with the Medium API, through the official API, and a 3rd-party

README 文档

README

A small PHP SDK to interact with Medium's API, both through a 3rd-party API via RapidApi (https://rapidapi.com/nishujain199719-vgIfuFHZxVZ/api/medium2/), and Medium's official REST API (https://github.com/Medium/medium-api-docs), where the former fills in the gaps of the latter (e.g., allowing a user to obtain their own posts).

At Packagist:

https://packagist.org/packages/gsmpopovic/medium-api

Install using Composer:

composer require gsmpopovic/medium-api

Setup:

  1. Install via Composer.
composer require gsmpopovic/medium-api
  1. Add .env variables:
RAPID_API_MEDIUM_API_KEY= xxx 
RAPID_API_MEDIUM_API_HOST= xxx
MEDIUM_USER_NAME= xxx 

OFFICIAL_MEDIUM_API_ACCESS_TOKEN= xxx
OFFICIAL_MEDIUM_API_VERSION=v1
  1. Use classes in your code, as per the example files.

NB:

To interact with the official API, you must generate an access token.

All credentials should be set as environment variables, but, barring this, can be manually assigned to the client as properties.

Examples of API usage can be found in the src/examples directory, both for the official Medium API, and 3rd party Rapid API.

e.g.,

// Official Medium API Use cases 

require_once "../MediumApi.php";
require_once "../Env.php";
require_once "../Request.php";

// or, if you're using composer, and have installed this package 

require "vendor/autoload.php";


use gsmpopovic\MediumApi\MediumApi;
use gsmpopovic\MediumApi\Env;
use gsmpopovic\MediumApi\Request;


/* 
You should only load the .env 
if it hasn't already been loaded elsewhere, as in Laravel. 
*/
$path = dirname(__DIR__, 1) . DIRECTORY_SEPARATOR . ".env";

$env = new Env($path);

$env->load();

$api = new MediumApi(new Request());

$api->getUser();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-19