Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('disqusapi/disqusapi.php');
- mysql_connect("localhost", "root", "");
- mysql_select_db("disqus");
- $DisqusAPI = new DisqusAPI('RG3K75F0XGExVIHl9moncwVmQZpjiG87G8NXTDUWacEkdvgSoZCW8G6nxFUsiDvk');
- // query our MAX datestamp
- /*$query = "SELECT nDA FROM news";
- if(!$result = mysql_query($query))
- {
- echo 'fail';
- }
- $row = mysql_fetch_object($result);
- echo $since = $row->nDA;*/
- //$since = "SELECT MAX(nDA) FROM news";
- $params = array("forum"=>"southerneastercamp","limit"=>100);
- //var_dump($params);
- //var_dump(json_encode($params));
- $jsonParams = json_encode($params);
- //var_dump($jsonParams);
- $error = json_last_error();
- var_dump($jsonParams, $error === JSON_ERROR_UTF8);
- /*foreach ($jsonParams as $string) {
- echo 'Decoding: ' . $string;
- json_decode($string);
- switch (json_last_error()) {
- case JSON_ERROR_NONE:
- echo ' - No errors';
- break;
- case JSON_ERROR_DEPTH:
- echo ' - Maximum stack depth exceeded';
- break;
- case JSON_ERROR_STATE_MISMATCH:
- echo ' - Underflow or the modes mismatch';
- break;
- case JSON_ERROR_CTRL_CHAR:
- echo ' - Unexpected control character found';
- break;
- case JSON_ERROR_SYNTAX:
- echo ' - Syntax error, malformed JSON';
- break;
- case JSON_ERROR_UTF8:
- echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
- break;
- default:
- echo ' - Unknown error';
- break;
- }
- echo PHP_EOL;
- }*/
- // fetch newer than posts from API
- try {
- $posts = $DisqusAPI->forums->listPosts($jsonParams);
- //$posts = $DisqusAPI->forums->listPosts({"forum":"southerneastercmap","since":(int)$since,"limit":100});
- //foreach ($posts as $post) {
- //save($post);
- //}
- } catch (Exception $e) {
- echo 'Caught exception: ', $e->getMessage(), "\n";
- }
- // save posts locally
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement