PHP code example of anycomment / php-sdk

1. Go to this page and download the library: Download anycomment/php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

anycomment / php-sdk example snippets




nyComment\Api;
use AnyComment\Config;

$apiKey = 'YOUR-API-KEY'; // Replace with your key
$config = new Config($apiKey);
$api = new Api($config);

var_dump($api->getWebsite()->getInfo());

class AnyComment\Dto\Envelopes\ResponseEnvelope#27 (3) {
  public $status =>
  string(2) "ok"
  public $response =>
  class AnyComment\Dto\Website\AppInfo\AppInfo#26 (2) {
    public $id =>
    int(1)
    public $url =>
    string(21) "https://anycomment.io"
  }
  public $error =>
  NULL
}

$data = $api->getWebsite()->getInfo();

$data = $api->getPage()->getCommentCount('https://anycomment.io/demo');

$data = $api->getProfile()->getInfo(1, 'oauth-token');

var_dump($api->getComment()->getList());

$page = new Page(
    'https://anycomment.io/demo',
    'Demo'
);
$comment = new Comment(
    1,
    null,
    1,
    'This is my comment',
    '127.0.0.1',
    date('Y-m-d H:i:s')
);
$author = new Author('John Doe');

$createRequest = new CommentCreateRequest(
    $page,
    $comment,
    $author
);

var_dump($api->getComment()->create($createRequest));
bash
composer