disqus / disqus-php Goto Github PK
View Code? Open in Web Editor NEWDisqus API bindings for PHP
Home Page: http://disqus.com/api/
License: Apache License 2.0
Disqus API bindings for PHP
Home Page: http://disqus.com/api/
License: Apache License 2.0
This library hasn't been updated in 5 years.
Does this library work with version 3.0 of the Disqus API?
Is it possible to add the community likes to the API
I like to add that feature to the drupal module.
Warning: Undefined array key 0 in DisqusResource->__call() (line 78 of /app/vendor/disqus/disqus-php/disqusapi/disqusapi.php)
It will be useful and simple to integrate with frameworks apps etc.
Thanks
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',
) );
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
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?
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.
Running the code in the README :
require 'disqus-php/disqusapi/disqusapi.php';
$disqus = new DisqusAPI(DISQUS_SECRET_KEY);
$threads = $disqus->trends->listThreads();
var_dump($threads);
outputs a notice message :
PHP Notice: Undefined offset: 0 in disqus-php/disqusapi/disqusapi.php on line 79
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);
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! :)
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!
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
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);
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!
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?
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'));
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.
I see python lib suports pagination, but it is lacking over here. Please support it.
Thanks
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.