Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>By default, Disqus API applications are now set to use OAuth so you have to add an 'access_token' argument to this example. There are two ways to get an the access token:</p> <ol> <li>Use our OAuth flow and let the user log in with their Disqus account -- you won't include <code>author_name</code> or <code>author_email</code> if you use this method</li> <li>Use your site owner access token (do this for guest comments like in your example above)</li> </ol> <p>Here's the documentation on OAuth works with Disqus: <a href="http://disqus.com/api/docs/auth/" rel="nofollow">http://disqus.com/api/docs/auth/</a> -- note that the site owner's access token can be found in your application overview here: <a href="http://disqus.com/api/applications/" rel="nofollow">http://disqus.com/api/applications/</a></p> <p>Here's an example of how to let a user authenticate, and then give you an access token: <a href="https://github.com/disqus/DISQUS-API-Recipes/tree/master/php/oauth" rel="nofollow">https://github.com/disqus/DISQUS-API-Recipes/tree/master/php/oauth</a></p> <p>Once you've acquired an access token, the script should look like this:</p> <pre><code>&lt;?php ini_set('display_errors', 'on'); $thread="XXXXXXXXX"; // e.g., 455718495 — you'll need to also create a $forum and pass that if you know only the thread's URL or identifier rather than the ID $api="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; // Generate one at http://disqus.com/api/applications/ -- Secret key is required for anonymous comment posting $message="Hello world."; // this is the content of the comment, i.e., what you'd normally type in the postbox $author_email="mail.user@mail.com"; // optional, including this will still make the comment a guest comment, but it will now be claimable $author_name="user"; // optional, can be any display name you like $fields_string=""; // DO NOT EDIT $access_token="YOUR_ACCESS_TOKEN"; // set POST variables $url = 'http://disqus.com/api/3.0/posts/create.json'; // full documentation at http://disqus.com/api/docs/posts/create/ $fields = array( 'api_secret'=&gt;urlencode($api), // change to api_key when using a public key 'thread'=&gt;urlencode($thread), 'message'=&gt;urlencode($message), 'author_email'=&gt;urlencode($author_email), 'author_name'=&gt;urlencode($author_name), 'access_token'=&gt;urlencode($access_token), ); // rest of script ... ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload