PHP Classes

disqus support

Recommend this page to a friend!

      PHP OAuth Library  >  All threads  >  disqus support  >  (Un) Subscribe thread alerts  
Subject:disqus support
Summary:any one added disqus to list of servers
Messages:6
Author:Mike Horton
Date:2013-07-13 21:01:25
Update:2013-10-13 08:36:03
 

  1. disqus support   Reply   Report abuse  
Picture of Mike Horton Mike Horton - 2013-07-13 21:01:25
I am trying to support login with Disqus (www.disqus.com). I think I have everything write and it logs me in fine. I see a URL coming back

I set the following:

case 'Disqus':
$this->oauth_version = '2.0';
$this->dialog_url = 'https://disqus.com/api/oauth/2.0/authorize/?client_id={CLIENT_ID}&scope={SCOPE}&response_type=code&redirect_uri={REDIRECT_URI}&state={STATE}';

$this->access_token_url = 'https://disqus.com/api/oauth/2.0/access_token';

I am quite sure it is authorizing me fine as I go to disqus and am logged in.

The problem I have is that it sends back a 302 code and unable to get token. if i ignore the 302 authorization->error, it still sees the token response as empty

If anyone has any ideas or has tested on Disqus I would greatly appreciate it.

  2. Re: disqus support   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-07-13 23:27:18 - In reply to message 1 from Mike Horton
I tried it here and it works. Are you sure you did not switch the public by the secret key?

If not, it is better to enable debugging and show what appears in your PHP error log.

  3. Re: disqus support   Reply   Report abuse  
Picture of Mike Horton Mike Horton - 2013-07-14 01:53:53 - In reply to message 2 from Manuel Lemos
Hi Manuel,
Thanks for getting back to me. Your code is working great for me on the out-of-the-box servers. I tryed swapping the two keys and got a invalid client id response, so I think I had them correct. Perhaps you can send your case: 'Disqus' code, maybe i have some error there. Here is the error log. I am sure I am doing something stupid :-(

[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] OAuth client: Checking if OAuth access token was already retrieved from https://disqus.com/api/oauth/2.0/access_token
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] OAuth client: Checking the authentication state in URI /oauth-api-2013-04-23/login_with_disqus.php?state=1373738641-5bae45&code=b3bf49a451a345f2abbe9d4021bcaca8
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] OAuth client: Checking the authentication code
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] OAuth client: Accessing the OAuth access token at https://disqus.com/api/oauth/2.0/access_token
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] Connecting to disqus.com
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] Resolving HTTP server domain "disqus.com"...
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] Connecting to HTTP server IP 173.192.42.190 port 443...
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] Connected to disqus.com
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] C POST /api/oauth/2.0/access_token HTTP/1.1
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] C Host: disqus.com
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] C User-Agent: PHP-OAuth-API (http://www.phpclasses.org/oauth-api $Revision: 1.58 $)
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] C Accept: */*
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] C Connection: Keep-Alive
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] C Content-Type: application/x-www-form-urlencoded
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] C Content-Length: 310
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] C
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] C code=b3bf49a451a345f2abbe9d4021bcaca8&client_id=80whR9HAsDQqRd78cMb7ACmYtmTJslwFvcJyZkpNvpSJ0B5zlD0UGuo6sBnfnh2g&client_secret=m7sdZx2TTQ6m7nxvyfDpTbCuWAwYHcwDDGynVyVh3wYp5MY18VzFEMG8MSX9R3Tn&redirect_uri=http%3A%2F%2Fwww.yabberz.com%2Foauth-api-2013-04-23%2Flogin_with_disqus.php&grant_type=authorization_code
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] S HTTP/1.1 301 MOVED PERMANENTLY
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] S Server: nginx
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] S Date: Sun, 14 Jul 2013 01:47:16 GMT
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] S Content-Type: text/html; charset=utf-8
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] S Transfer-Encoding: chunked
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] S Connection: close
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] S p3p: CP="DSP IDC CUR ADM DELi STP NAV COM UNI INT PHY DEM"
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] S Location: https://disqus.com/api/oauth/2.0/access_token/
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] S Alternate-Protocol: 443:npn-spdy/2
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] S
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] S 0
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] S
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] Disconnected from disqus.com
[Sun Jul 14 01:45:57 2013] [error] [client 108.217.161.128] OAuth client: Could not retrieve the OAuth access. Error: it was not possible to access the OAuth access token: it was returned an unexpected response status 301 Response:

  4. Re: disqus support   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-07-14 02:15:26 - In reply to message 3 from Mike Horton
You are missing a slash / at the end of the access token URL. That is why Disqus API is redirecting the access token request to the correct URL. The class does not handle the redirect because it is a POST request and redirects are GET requests, so it would not work.

  5. Re: disqus support   Reply   Report abuse  
Picture of Mike Horton Mike Horton - 2013-07-14 03:09:08 - In reply to message 4 from Manuel Lemos
Hi Manuel,

I got it working and getting tokens and profiles etc ! Thanks. I had a little trouble getting the API call working (passing the api_key to it) and tried to pass api key thru the array() parameter after 'GET'. It did not work. However the brute force approach below worked. Let me know if there is a better way to do the actual API call.

Thanks again for the wonderful library.

$success = $client->CallAPI(
'https://disqus.com/api/3.0/users/details.json?api_key='.$client->client_id,
'GET', array(), array('FailOnAccessError'=>true), $user);

Mike

  6. Re: disqus support   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-10-13 08:36:03 - In reply to message 5 from Mike Horton
Sorry for the delay. I am not sure what you mean by brute force. You're call to CallAPI looks fine.