kamankily
kamankily

Reputation: 91

How to create category in Disqus

I need to creating some categories in Disqus. I tried to do it by Javascript but it cannot do because require POST request but JSONP only work with GET request. After that, I tried to use CURL in server-side, there are my code

public function createDisqusCategory($title, $forum)
{
    $access_token = ACCESS_TOKEN;
    $secret_key = SECRET_KEY;
    $public_key = PUBLIC_KEY;

    $url = 'https://disqus.com/api/3.0/categories/create.json';
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: application/json'));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "access_token=$access_token&api_secret=$secret_key&api_key=$public_key&forum=$forum&title=$title");
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}

and it response {"code": 22, "response": "You do not have admin privileges on forum '...'"}

How can I solve this problem?

Upvotes: 1

Views: 787

Answers (1)

Ryan V
Ryan V

Reputation: 3100

Does your application have Default access set to "Read, write and manage forums"? If not, you'll either need to add a "scope" parameter to your POSTFIELDS, or set default access to manage forums in your application settings. Here's our documentation on scopes: http://disqus.com/api/docs/permissions/

On another note, categories in Disqus are limited to use with the API, so it's not useful in any way unless you're querying comments/threads using a custom script. If you are, I'd also advise keeping it to about 5 categories maximum, or else it can really slow down queries.

Upvotes: 1

Related Questions