Skip to content

vonlab/articleforge

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ArticleForge

PHP Implementation of ArticleForge API.

Installation

Install via composer

composer require ruslanstarikov/articleforge

Usage

<?php
declare(strict_types=1);
use Ruslanstarikov\Articleforge;

$apiKey = 'FAKE-ARTICLE-FORGE-KEY';

// initiate ArticleForge class
$articleForge = new ArticleForge($apiKey);

// create a new article
$initArticleResponse = $articleForge->initiateArticle($keywords); 

// Get the reference key for the new article
$referenceKey = $initArticleResponse->getRefKey();
// Also
$referenceKey = $initArticleResponse->toArray()['refKey'];

Official Documentation

Official API documentation can be accessed here: https://af.articleforge.com/api_info [Last accessed on 09/02/2023]

Methods

checkUsage

Arguments: none Example:

$initArticleResponse = $articleForge->checkUsage(); 

Response: CheckUsageResponse object. toArray method returns the following output

return [
            'status' => $this->getStatus(),
            'apiRequests' => $this->getApiRequests(),
            'monthlyWordsRemaining' => $this->getMonthlyWordsRemaining(),
            'overuseProtection' => $this->getOveruseProtection(),
            'prepaidAmount' => $this->getPrepaidAmount(),
            'prepaidWordsAvailable' => $this->getPrepaidWordsAvailable(),
            'overageUsageCharge' => $this->getOverageUsageCharge(),
            'error' => $this->getErrorMessage()
];

viewArticles

Arguments:

limit - integer, optional Example:

$initArticleResponse = $articleForge->viewArticles(10); 

Response: ArticleListResponse object. toArray method returns the following output

return [
        'data' => [
            [
                'id' => $this->getId(),
                'title' => $this->getTitle(),
                'createdAt' => $this->getCreatedAt()->format('c'),
                'keyword' => $this->getKeyword(),
                'subKeywords' => $this->getSubKeywords()
            ],
        ],
        'status' => $this->getStatus(),
        'error' => $this->getErrorMessage()
];

viewArticle

Arguments:

articleId - integer, required spintaxView - boolean, false

Example:

$initArticleResponse = $articleForge->viewArticle(123); 

Response: ArticleResponse Object. toArray method returns the following:

return [
        $this->setData($response['data']);
        $this->setStatus($response['status']);
]

initiateArticle

Arguments: keyword - string, mandatory

length - string, articleLength, optional. Refer to ArticleLength enum

subKeywords - string, optional

title - boolean, optional

image - float from 0.0 to 1.0, optional

video - float from 0.0 to 1.0, optional

autoLinks - array, optional

turingSpinner - boolean, optional,

quality - integer, optional

uniqueness - integer, optional,

useSectionHeading - boolean, optional

sectionHeadings - array of strings, optional

rewriteNum - integer, optional

excludedTopics - array, optional

instructions - string, optional

seEvade - boolean, optional

Example:

$title = "Health benefits of bacon";
$length = ArticleLength::MEDIUM;

$initArticleResponse = $articleForge->initiateArticle($title, $length); 

Response: InitiateArticleResponse object. toArray method returns the following structure

        return [
            'refKey' => $this->getRefKey(),
            'status' => $this->getStatus(),
            'error' => $this->getErrorMessage()
        ];

getApiProgress

Arguments:

RefKey: integer, mandatory

$articleId = 213;

$initArticleResponse = $articleForge->getApiProgress($articleId); 

Response: GetApiProgressResponse object. toArray method returns the following structure

        return [
            'apiStatus' => $this->getApiStatus(),
            'progress' => $this->getProgress(),
            'status' => $this->getStatus(),
            'error' => $this->getErrorMessage()
        ];

getApiArticleResult

Arguments:

RefKey: integer, mandatory

$articleId = 213;

$initArticleResponse = $articleForge->getApiArticleResult($articleId); 

Response: ApiArticleResultResponse object. toArray method returns the following structure

 return [
            'article' => $this->getArticle(),
            'articleId'=> $this->getArticleId(),
            'status' => $this->getStatus(),
            'error' => $this->getErrorMessage()
];

deleteArticle

Arguments:

RefKey: integer, mandatory

$articleId = 213;

$initArticleResponse = $articleForge->deleteArticle($articleId); 

Response: DeleteArticleResponse object. toArray method returns the following structure

        return [
            'status' => $this->getStatus(),
            'errorMessage' => $this->getErrorMessage()
        ];

About

PHP Implementation of Article Forge API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%