devkind/writesonic-php 问题修复 & 功能扩展

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

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

devkind/writesonic-php

最新稳定版本:v1.1

Composer 安装命令:

composer require devkind/writesonic-php

包简介

README 文档

README

Latest Version on Packagist Total Downloads GitHub Actions

WritesonicPhp is a simple SDK implementation of Writesonic API. It helps accessing the API in an object oriented way.

Getting the API key

please register an account and request an api key at Writesonic.
Please check out the tutorials section for more information

Installation

You can install the package via composer:

composer require devkind/writesonic-php

Usage

Initialization:

use Devkind\WritesonicPhp;

/** @var \Devkind\WritesonicPhp */
$writesonic  =  new WritesonicPhp(API_KEY);

alternatively we can initialize static

/** @var \Devkind\WritesonicPhp */
$writesonic  =  \Devkind\WritesonicPhp::make(API_KEY);

Endpoint:

Endpoints are basically the type of content that is supported by Writesonic.

Each endpoint requireds an $engine and $language parameter to query from writesonic.

    /** @var string $language */
    protected $language = 'en';

    /** @var string $engine */
    protected $engine = 'economy';

it supports following engines :

economy, business

and it supports following languages :

en, nl, fr, de, it, pl, es, pt-pt, pt-br, ru, ja, zh, bg, cs, da, el, hu, lt, lv, ro, sk, sl, sv, fi, et

in order to change the language or engine we can call the setter methods, which is available on all the endpoints.

to set the language

/** @var \Devkind\WritesonicPhp\Endpoints\GenerateImage */
$endpoint = $writesonic->GenerateImage->setLanguage('br');

to set the engine

/** @var \Devkind\WritesonicPhp\Endpoints\GenerateImage */
$endpoint = $writesonic->GenerateImage->setEngine('business');

alternatively:

/** @var \Devkind\WritesonicPhp\Endpoints\GenerateImage */
$endpoint = $writesonic->GenerateImage->setEngine('br')->setLanguage('br');

Supported Objects / Endpoints and Usage detail:

All the endpoints can be called into three different ways

as a payload

$object  =  new WritesonicPhp('test123');
/** @var \Devkind\WritesonicPhp\Endpoints\GoogleAds */
$endpoint = $object->GoogleAds;

$array = $endpoint->setPayload([
    "product_name" => 'test',
    "product_description" => 'test',
    "search_term" => 'test',
])->get();

through the setter methods

$object  =  new WritesonicPhp('test123');
/** @var \Devkind\WritesonicPhp\Endpoints\GoogleAds */
$endpoint = $object->GoogleAds;
/** @var array */
$array = $endpoint->setProductName('test')
    ->setProductDescription('test')
    ->setSearchTerm('test')
    ->get();

through the generate method

/** @var \Devkind\WritesonicPhp\Endpoints\GoogleAds */
$endpoint = $writesonic->GoogleAds;
/** @var array */
$endpoint->generate(
	$product_name,
	$product_description,
	$search_term
);

through the get method

/** @var array */
$endpoint = $writesonic->GoogleAds->get([
    "product_name" => 'test',
    "product_description" => 'test',
    "search_term" => 'test',
]);
Click here to view the entire documentation of supported endpoints

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email backend@devkind.com.au instead of using the issue tracker.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-02