Git Product home page Git Product logo

disqus-php's Introduction

disqus-php

Requires PHP 5.3.0 or newer!

Use the API by instantiating it, and then calling the method through dotted notation chaining:

require('disqusapi/disqusapi.php');
$disqus = new DisqusAPI($secret_key);
$disqus->trends->listThreads();

Parameters (including the ability to override version, api_secret, and format) are passed as keyword arguments to the resource call:

$disqus->posts->details(array('post'=>1, 'version'=>'3.0'));

Documentation on all methods, as well as general API usage can be found at http://disqus.com/api/

disqus-php's People

Contributors

anhnt avatar dcramer avatar tail avatar typhonius avatar williamdenniss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

disqus-php's Issues

Minimum required PHP version

README.rst mentions PHP 5.3 as the minimum required version but from a quick code analysis with this neat little tool, it's actually 5.2 and just for json_decode().

For all the rest you only need PHP 5.1. Could you please confirm this and, if correct, change the docs accordingly?

Thanks! :)

data=false code=0

Hi,

I'm testing disqus-php from my localhost like this:

$disqus = new DisqusAPI($secret_api);
$data = array('forum' => $forum_shortname);
return $disqus->posts->list($data);

But,
$response = dsq_urlopen($url.$path, $post_data);
Returns,
array(2) { ["data"]=> bool(false) ["code"]=> int(0) }

Any help would be appreciated

Fatal error: Uncaught exception 'DisqusAPIError'

I use the demo

require __DIR__ . '/disqusapi/disqusapi.php';
$disqus_key = {MY_SECRET_KEY};
$disqus = new DisqusAPI($disqus_key);
var_dump($disqus->trends->listThreads());

The ouput is:

Notice: Undefined offset: 0 in /var/www/myapi/public/disqusapi/disqusapi.php on line 78

Notice: Undefined index: content-length in /var/www/myapi/public/disqusapi/url.php on line 181

Notice: Trying to get property of non-object in /var/www/myapi/public/disqusapi/disqusapi.php on line 115

Notice: Trying to get property of non-object in /var/www/myapi/public/disqusapi/disqusapi.php on line 115

Fatal error: Uncaught exception 'DisqusAPIError' in /var/www/myapi/public/disqusapi/disqusapi.php:115 Stack trace: #0 /var/www/myapi/public/disqustest.php(13): DisqusResource->__call('listThreads', Array) #1 /var/www/myapi/public/disqustest.php(13): DisqusResource->listThreads() #2 {main} thrown in /var/www/myapi/public/disqusapi/disqusapi.php on line 115

what should I do to fix it? Thanks!

fsockopen does not work

I need to have curl extension enabled to make it work properly.

If curl is disabled, fsockopen is used and it fails because Disqus server always returns 400 Bad Request HTTP error.

Code is:

require 'disqus-php/disqusapi/disqusapi.php';

$disqus = new DisqusAPI(DISQUS_SECRET_KEY);
$threads = $disqus->trends->listThreads();
var_dump($threads);

How do you get all the threads listed?

How do you get all the threads listed?

I can't figure out the cursor.

Here's my code:
function listThreads($cursor,$incurrences) {
global $setting;
global $disqus;
$incurrences = $incurrences+1;
$params = array('forum' => $setting['disqus_forum'], 'order' => 'desc', 'limit' => 90);
if($cursor != 0) {
$params['cursor'] = $cursor;
}
echo $cursor.'
';
$i = 0;
$threads = $disqus->threads->list($params);
$cursor = $cursor+90;
foreach ($threads as $thread) {
$i = $i+1;
$id = $thread->id;
$title = $thread->title;
$link = $thread->link;
$date = date('Y-m-d H:i:s',strtotime($thread->createdAt."+0000"));
if(mysql_num_rows(mysql_query("SELECT * FROM disqus_threads where thread_id = '$id' and title = '$title'")) == 0) {
$insert = mysql_query("INSERT INTO disqus_threads (thread_id,title,link,date) VALUES ('$id','$title','$link','$date')") or die(mysql_error());
}
}

  if($i == 90 && $incurrences != 2) {
            $cursor = $cursor->next;
            listThreads($cursor,$incurrences);
  }
}
listThreads(0,0);

Lack of method posts->update

I found that there is no posts->update method in interfaces.json. I have added it but how can i push my local branch and create a pull request?
update: I've created a pull request

The example Data synchronization code from Disqus Docs, Broken.

The example at http://docs.disqus.com/help/58/ referring to this PHP Class, seems to be broken.

I continue to get:
Caught exception: Missing required argument: forum

I've done numerous tests to see if the 'forum' is actually passed and I believe it is, but still the same.

http://stackoverflow.com/questions/8426301/disqus-data-synchronization-with-php-api/8583525#8583525

If you copy paste that example directly (including ur own API key and forum name of course) and you will get an error:
Parse error: syntax error, unexpected '{', expecting ')'

Invalid PHP. a number of other devs and I can't make this work, help?

Support pagination

I see python lib suports pagination, but it is lacking over here. Please support it.

Thanks

PHP Notice: Trying to get property of non-object in disqus-php/disqusapi/disqusapi.php on line 120

PHP Notice: Trying to get property of non-object in /home/ceefour/git/bippo-labs/disqus-sandbox/disqus-php/disqusapi/disqusapi.php on line 120

The following code:

require 'disqus-php/disqusapi/disqusapi.php';

$disqus = new DisqusAPI(DISQUS_SECRET_KEY);
$threads = $disqus->trends->listThreads();
var_dump($threads);

outputs this notice :

PHP Notice:  Trying to get property of non-object in disqus-php/disqusapi/disqusapi.php on line 120

and the result is :

NULL

However, checking using curl, the following works:

curl 'https://disqus.com/api/3.0/trends/listThreads.json?api_secret=[[SECRET_KEY]]'

and outputs the trending threads in JSON format.

Optimize Interfaces.json?

I realize this may seem a bit OCD, but I actually made an API parser plugin for CakePHP (haven't made a disqus one yet though). I made use of an 'api map' which is the equivalent to your interfaces file, however I had only 2 thoughts:

Wouldn't it reduce the footprint to 1. make the 'required' field optional and 2. group interfaces under the method type?

Here is one of my examples: https://github.com/ProLoser/CakePHP-Github/blob/master/config/github.php

Although there is extra information in there that I use but the main idea is the same, things are just grouped by CRUD.

Otherwise, feel free to close this ticket, it was just a thought that popped into my head reviewing your code for integration, heh.

Undefined property "set" on Disqus PHP API Library

Just wondering if someone else faced this issue. I'm trying to retrieve multiple thread details with SET property using PHP API, but as far I see it's not implemented yet.
The property DETAILS is working fine so far, but I need to get many threads and several calls to DETAILS is not an option.

$disqus = new DisqusAPI($secret_key);
$disqus->threads->set(Arguments........................)

Any help?

searching for thread via URL

Hi guys

I am trying to search for a thread withing my forum via the URL/Link ... I am trying to do it in the following manner.

$params = array(
'forum' => $this->shortname,
'thread' => ("link:" . $URL)
);

$thread = $this->API->threads->list($params);

However the URL filtering is not working as desired since the results of that call contains all the thread of my forum.

Any advice?

Thanks

Community likes

Is it possible to add the community likes to the API
I like to add that feature to the drupal module.

threads/details requirements needs tweaking

In interfaces.json (~line 515), the 'thread' parameter is required for threads/details, but in the documentation, you can also provide thread:link or thread:ident if you don't know the thread ID. But if you try:

    $thread = $disqus->threads->details( array(
        'forum' => 'myforum-temp',
        'thread:link' => $thread_data['link'],
    ) );

This throws an exception: Exception: Missing required argument: thread in DisqusResource->__call() (line 82 of /path/to/disqus-php/disqusapi/disqusapi.php).

You can workaround this by providing a dummy ID, which seems to work:

    $thread = $disqus->threads->details( array(
        'forum' => 'myforum-temp',
        'thread:link' => $thread_data['link'],
        'thread' => '123',
    ) );

use of global scope for $DISQUS_API_INTERFACES

In disqusapi.php

Line 40 defines $DISQUS_API_INTERFACES:
$DISQUS_API_INTERFACES = dsq_json_decode(file_get_contents(dirname(FILE) . '/interfaces.json'));

Line 53 Attempts to access it in the global scope:
global $DISQUS_API_INTERFACES;

The problem is that Line 40 only adds that variable to the global scope if the disqusapi.php is included within the global context. If disqusapi.php is included via class autoload, or from within any other class or function, then the $DISQUS_API_INTERFACES inside DisqusResource:__construct returns NULL

One way to fix this is to put on line 39:
global $DISQUS_API_INTERFACES;

Another way to fix it would be to:
- Line 53 global $DISQUS_API_INTERFACES;
Line 54 $interface = dsq_json_decode(file_get_contents(dirname(FILE) . '/interfaces.json'));

DisqusAPIError constructor extends PHP Exception but switches arguments around

I just noticed that DisqusAPIError subclasses a normal PHP Exception but for some weird reason decided to switch the arguments around - why?

DisqusAPIError: __construct($code, $message)

Standard PHP Exception: __construct ([ string $message = "" [, int $code = 0 [, Exception $previous = NULL ]]] )

Doesn't make sense to me to switch the params around - it just leads to confusion!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.