Script that will allow users to post a comment to a URL’s page with Disqus enabled

Is it possible to create, for example, a PHP script that will allow users to post a comment to the web page of the other website with Disqus comments enabled, with the URL that inputted by the user?

  1. Users will input the URL of the other website’s page with Disqus comments enabled.
  2. They will also input the comment that they want.
  3. And the last is to submit.. (Also, please provide the other required arguments that aren’t listed here!)

If it’s possible, what are the procedures and the steps to achieve this kind of script?

Read More

Actually, after contacting Disqus Support, they said this:

You can post comments via our API. More information on our API can be found here: http://disqus.com/api

But I don’t have a clue where can I start it, that’s why I’m here..

Related posts

Leave a Reply

1 comment

  1. In order to do that, you can do following steps;

    1.) Get disqus php api library here

    2.) Register an application here and get API Key and API Secret

    3.) Create form with minimal requirements;

    <form action="comment_send.php" method="POST">
        <table>
            <tr>
                <td>Name: </td>
                <td><input type="text" name="c_name" value=""/></td>
            </tr>
            <tr>
                <td>Email: </td>
                <td><input type="text" name="c_email" value=""/></td>
            </tr>
            <tr>
                <td>Thread ID: </td>
                <td><input type="text" name="c_thread_id" value=""/></td>
            </tr>
            <tr>
                <td>Comment: </td>
                <td><input type="text" name="c_comment" value=""/></td>
            </tr>
            <tr>
                <td colspan="2"><input type="submit" name="create_comment" value="Create Comment"/></td>
            </tr>
        </table>
    </form>
    

    4.) Write a handler for this form;

    comment_send.php

    require 'path/to/disqusapi.php';
    
    $secret_key = API_SECRET;
    $api_key = API_KEY;
    
    $thread_id = $_POST["c_thread_id"]; // Url of the thread disqus enabled
    $message = $_POST["c_comment"];
    $author_name = $_POST["c_name"];
    $author_email = $_POST["c_email"];
    
    $disqus = new DisqusAPI($secret_key);
    $res = $disqus->posts->create(array(
        'thread' => $thread_id,
        'message' => $message,
        'author_name' => $author_name,
        'author_email' => $author_email,
        'api_key' => $api_key,
    ));
    
    echo "Comment send result: " . $res;