Skip to content

yuanbenio/yb-openapi-sdk-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yuanben/yb-openapi-sdk-php

Usage

Media

$config = new Config($token, Config::USER_MEDIA);

$client = new Client($config);

$title = 'Hello World.';
$content = 'DearMadMan.';
$article = new Article($title, $content);

$license = new License(License::LICENSE_CC);
$license->setAdaptation(License::LICENSE_CC_ADAPTATION_Y)->setCommercial(License::LICENSE_CC_COMMERCIAL_N);

$article->setLicense($license);

$response = $client->post($article);

var_dump($response instanceof Article);

// multiple data
$collect = new Collection();

$article2 = new Article('The Title Of Article 2.', 'The Body.');
$article2->setLicense($license);

$collect->push($article)->push($article2);

$response = $client->post($collect);

var_dump($response instanceof Colletion);

Platform

$config = new Config($token, Config::USER_PLATFORM);

$client = new Client($config);

$title = 'Hello World.';
$content = 'DearMadMan.';
$article = new Article($title, $content);

$license = new License(License::LICENSE_CC);
$license->setAdaptation(License::LICENSE_CC_ADAPTATION_Y)->setCommercial(License::LICENSE_CC_COMMERCIAL_N);

$author = new Author('[email protected]', 'DearMadMan.');

$article->setLicense($license)
    ->setAuthor($author);

$response = $client->post($article);


// multiple data
$collect = new Collection();

$article2 = new Article('The Title Of Article 2.', 'The Body.');
$article2->setLicense($license)
    ->setAuthor($author);

$collect->push($article)->push($article2);

$response = $client->post($collect);


License Instance

$license = License::fromJson($json);

Exception

try {
$response = $client->post($collect);
} catch (\Exception $e) {
    echo $e->getMessage();
}

About

Yuanben OpenAPI PHP SDK

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages