コード例 #1
0
ファイル: threadsRemove.php プロジェクト: compwright/disguz
<?php

require_once 'vendor/autoload.php';
use compwright\Disguz\Disguz;
// Create a client and pass an array of configuration data
$config = ['disqus.keys' => ['api_key' => getenv('DISQUS_API_KEY'), 'api_secret' => getenv('DISQUS_API_SECRET'), 'access_token' => getenv('DISQUS_ACCESS_TOKEN')]];
$client = Disguz::factory($config);
$params = ['thread' => $argv[1]];
$result = $client->threadsRemove($params);
print_r($result);
コード例 #2
0
ファイル: heartbeat.php プロジェクト: compwright/disqus-demo
#!/usr/bin/env php
<?php 
namespace compwright\DisqusDemo;

require_once 'bootstrap.php';
use compwright\Disguz\Disguz;
use Guzzle\Http\Exception\HttpException;
use Aura\Cli\CliFactory;
use Aura\Cli\Status;
use Memcache;
$factory = new CliFactory();
$stdio = $factory->newStdio();
// Create a client and pass an array of configuration data
$client = Disguz::factory(['disqus.keys' => ['api_key' => getenv('DISQUS_API_KEY')]]);
// Connect to burst cache
$memcache = new Memcache();
list($host, $port) = explode(':', getenv('MEMCACHED'));
$connected = $memcache->connect($host, $port);
if (!$connected) {
    throw new \Exception('Unable to connect to Memcache server, ' . getenv('MEMCACHED'));
}
$forum = getenv('DISQUS_FORUM');
$ttl = getenv('CACHE_TTL');
$healthyKey = getenv('CACHE_NAMESPACE') . '-healthy';
try {
    // Ping the Disqus API
    $client->threadsList(compact('forum'));
    // Save healthy status in burst cache
    $memcache->set($healthyKey, 'healthy', 0, $ttl);
    // Report status to the console
    $stdio->outln('healthy');
コード例 #3
0
ファイル: index.php プロジェクト: compwright/disqus-demo
$app->post('/', function () use($app) {
    $disqus = Disguz::factory(['disqus.keys' => ['api_key' => getenv('DISQUS_API_KEY'), 'api_secret' => getenv('DISQUS_API_SECRET'), 'access_token' => getenv('DISQUS_ACCESS_TOKEN')]]);
    $result = $disqus->threadsCreate(['forum' => getenv('DISQUS_FORUM'), 'title' => $app->request()->post('title')]);
    $app->redirect('/');
});
// List all the posts on a thread
$app->get('/discussion/:threadId', function ($thread) use($app) {
    $disqus = Disguz::factory(['disqus.keys' => ['api_secret' => getenv('DISQUS_API_SECRET')]]);
    $posts = $disqus->postsList(compact('thread'));
    $thread = $disqus->threadsDetails(compact('thread'));
    $app->render('discussion.php', ['posts' => $posts['response'], 'thread' => $thread['response']]);
});
// Create a new post on a thread
$app->post('/discussion/:threadId', function ($thread) use($app) {
    // Create a client and pass an array of configuration data
    $disqus = Disguz::factory(['disqus.keys' => ['api_secret' => getenv('DISQUS_API_SECRET')]]);
    $result = $disqus->postsCreate(['thread' => $thread, 'message' => $app->request()->post('message'), 'author_name' => $app->request()->post('author_name'), 'author_email' => $app->request()->post('author_email')]);
    $app->redirect('/discussion/' . $thread);
});
// Flag an objectionable post
$app->post('/discussion/:threadId/moderate/:postId', function ($thread, $post) use($app) {
    // Create a client and pass an array of configuration data
    $disqus = Disguz::factory(['disqus.keys' => ['api_secret' => getenv('DISQUS_API_SECRET')]]);
    $result = $disqus->postsReport(compact('post'));
    $app->redirect('/discussion/' . $thread);
});
$bench = new Ubench();
$bench->start();
$app->run();
$bench->end();
$app->render('benchmark.php', compact('bench'));