PHP Classes

PHP oAuth API

Recommend this page to a friend!

      PHP OAuth Library  >  All threads  >  PHP oAuth API  >  (Un) Subscribe thread alerts  
Subject:PHP oAuth API
Summary:Thanks, it's a great class!
Messages:31
Author:E.F. de moor
Date:2013-10-24 21:45:24
Update:2013-12-20 20:01:58
 
  1 - 10   11 - 20   21 - 30   31 - 31  

  21. Re: PHP oAuth API   Reply   Report abuse  
Picture of pradeep pradeep - 2013-11-16 13:16:22 - In reply to message 20 from pradeep
but these info are not getting entered into my database

  22. Re: PHP oAuth API   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-11-17 01:47:38 - In reply to message 19 from E.F. de moor
Sorry, I missed your last message.

Can you provide a complete sequence of API calls that you do so I can try to reproduce it here?

  23. Re: PHP oAuth API   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-11-17 01:49:36 - In reply to message 20 from pradeep
Yes, but you should take a look at the errors that it displays there so you can understand why it is not doing what you expect.

If you are not able to understand, just post the complete log messages here so I can try to understand what is going on.

  24. Re: PHP oAuth API   Reply   Report abuse  
Picture of E.F. de moor E.F. de moor - 2013-11-17 08:25:31 - In reply to message 22 from Manuel Lemos
Dear Manuel,

First of all thanks for considering my proposal.

The code I use is a more complex combination of classes, that works quite well. All derived from your oAuth class. I abstracted the code to the sequence of calls below. This should work, but I didn't test this code separately

The code below doesn't work with the unmodified oAuth class, because the authorization data isn't sent to Dropbox when the "delta" command is sent (which must be a post, according to the specs of Dropbox).

With the modification I proposed in the first message of this thread, the code below does work.

Hopefully you can reproduce it. Thanks in advance!

Ernst de Moor.


// $myClientId : Dropbox application client ID
// $myClientSecret: Secret code belonging to client ID
// $myRedirectUri: The URL Dropbox will refer back to after successfull approval
// $previousCursor: If any: the previous sync code Dropbox provided.

$client = new oauth_client_class();
$this->client_id = $myClientId;
$this->client_secret = $myClientSecret;
$this->redirect_uri = $myRedirectUri;
if($previousCursor)
$this->cursor = $previousCursor;
if(($success = $this->Initialize())) {
if(($success = $this->Process())) {
if($this->exit) {
echo "You are redirected to the Dropbox website for approval";
exit();
}
if(strlen($this->access_token))
{
$success = $this->CallAPI(
'https://api.dropbox.com/1/account/info',
'GET', array(), array('FailOnAccessError'=>true), $user
);
}
}
$success = $this->Finalize($success);
}
if(!$this->exit && $success) {
if($this->cursor)
$parms['cursor'] = $this->cursor;
$success = $this->CallAPI(
"https://api.dropbox.com/1/delta",
'POST',
$parms,
array('FailOnAccessError'=>true),
$delta
);
print_r($delta)
}
}




  25. Re: PHP oAuth API   Reply   Report abuse  
Picture of pradeep pradeep - 2013-11-17 12:26:06 - In reply to message 23 from Manuel Lemos
[16-Nov-2013 15:20:52] OAuth client: Checking if OAuth access token was already retrieved from https://graph.facebook.com/oauth/access_token
[16-Nov-2013 15:20:52] OAuth client: Checking the authentication state in URI /test/oauthphp/login_with_facebook.php
[16-Nov-2013 15:20:52] OAuth client: Redirecting to OAuth Dialog https://www.facebook.com/dialog/oauth?client_id=481884905258728&redirect_uri=http%3A%2F%2Fwww.minglcafe.com%2Ftest%2Foauthphp%2Flogin_with_facebook.php&scope=email&state=1384595452-908cc0
[16-Nov-2013 15:20:53] OAuth client: Checking if OAuth access token was already retrieved from https://graph.facebook.com/oauth/access_token
[16-Nov-2013 15:20:53] OAuth client: Checking the authentication state in URI /test/oauthphp/login_with_facebook.php?code=AQBwH2QKJITjmKrMqNwd2Gey4R7N4JniEPyiszE3ZZZiIJaf7gL9gFzG-WyMFMwsaji3ktMNTii6SdjKzhGkGST9kWkwCPC8d7vHCo7G4eOF2objtTRr7dudYrSLN4VOAKbe3bXllAqa9mUFfJN8SvglIpcgUQyAzaR67jTePGVj-p1IEV2sMNBeNkZL6YkddevY4htCsJrgUKVMllHWhl3S1xBNDMiasdVFgXVjWAz441w48H0Jo-KGWGiRaNwTtfXFH1vWDDd4wVqBQcujgSRsScYa9Cq-nefvFbL0U7h10j0WDRFetBVhvM5gZ1CN2As8rU&state=13845sdas95452-908cc0
[16-Nov-2013 15:20:53] OAuth client: Checking the authentication code
[16-Nov-2013 15:20:53] OAuth client: Accessing the OAuth access token at https://graph.facebook.com/oauth/access_token
[16-Nov-2013 15:20:53] Connecting to graph.facebook.com
[16-Nov-2013 15:20:53] Resolving HTTP server domain "graph.facebook.com"...
[16-Nov-2013 15:20:53] Connecting to HTTP server IP 31.13.70.33 port 443...
[16-Nov-2013 15:20:54] Connected to graph.facebook.com
[16-Nov-2013 15:20:54] C POST /oauth/access_token HTTP/1.1
[16-Nov-2013 15:20:54] C Host: graph.facebook.com
[16-Nov-2013 15:20:54] C User-Agent: PHP-OAuth-API (http://www.phpclasses.org/oauth-api $Revision: 1.74 $)
[16-Nov-2013 15:20:54] C Accept: */*
[16-Nov-2013 15:20:54] C Connection: Keep-Alive
[16-Nov-2013 15:20:54] C Content-Type: application/x-www-form-urlencoded
[16-Nov-2013 15:20:54] C Content-Length: 519
[16-Nov-2013 15:20:54] C
[16-Nov-2013 15:20:54] C code=AQBwH2QKJITjmKrMqNwd2Gey4R7N4JniEPyiszE3ZZZiIJaf7gL9gFzG-WyMFMwsaji3ktMNTii6SdjKzhGkGST9kWkwCPC8d7vHCo7G4eOF2objtTRr7dudYrSLN4VOAKbe3bXllAqa9mUFfJN8SvglIpcgUQyAzaR67jTePGVj-p1IEV2sMNBeNkZL6YkddevY4htCsJrgUKVMllHWhl3S1xBNDMiVFgXVjWAz441w48H0Jo-KGWGiRaNwTtfXFH1vWDDd4wVqBQcujgSRsScYa9Cq-nefvFbL0U7h10j0WDRFetBVhvM5gZ1CN2As8rU&client_id=481884905258728&client_secret=cfffdb41eb832d580b69261aedc770cd&redirect_uri=http%3A%2F%2Fwww.minglcafe.com%2Ftest%2Foauthphp%2Flogin_with_facebook.php&grant_type=authorization_code
[16-Nov-2013 15:20:54] S HTTP/1.1 200 OK
[16-Nov-2013 15:20:54] S Access-Control-Allow-Origin: *
[16-Nov-2013 15:20:54] S Cache-Control: private, no-cache, no-store, must-revalidate
[16-Nov-2013 15:20:54] S Content-Type: text/plain; charset=UTF-8
[16-Nov-2013 15:20:54] S Expires: Sat, 01 Jan 2000 00:00:00 GMT
[16-Nov-2013 15:20:54] S Pragma: no-cache
[16-Nov-2013 15:20:54] S X-FB-Rev: 1010817
[16-Nov-2013 15:20:54] S X-FB-Debug: JW5rKlQ5A89D5AkDmQiS3rI2+HDX5m6siA6H5Fh3yPY=
[16-Nov-2013 15:20:54] S Date: Sat, 16 Nov 2013 09:50:57 GMT
[16-Nov-2013 15:20:54] S Connection: keep-alive
[16-Nov-2013 15:20:54] S Content-Length: 215
[16-Nov-2013 15:20:54] S
[16-Nov-2013 15:20:54] S access_token=CAAG2RZAKZAvugBAI5bLM5Yin7SGtlXZBPkdSPXQ3pp7XLDNCM51G8ZAGXvK05v0n4FBqGyZC9j4hG9dNP9EGDkAFjDCcVQ92qhGlic2Kylelk58Vl6vQZCAvtQd81BisZAyl48WK22khlAOmksksXZBv2Rxnj05V6drMvZBGlPQJJYNiwryRsn8Lv&expires=5183997
[16-Nov-2013 15:20:54] Keeping the connection alive to graph.facebook.com
[16-Nov-2013 15:20:54] OAuth client: Access token: CAAG2RZAKZAvugBAI5bLM5Yin7SGtlXZBPkdSPXQ3pp7XLDNCM51G8ZAGXvK05v0n4FBqGyZC9j4hG9dNP9EGDkAFjDCcVQ92qhGlic2Kylelk58Vl6vQZCAvtQd81BisZAyl48WK22khlAOmksksXZBv2Rxnj05V6drMvZBGlPQJJYNiwryRsn8Lv
[16-Nov-2013 15:20:54] OAuth client: Access token expiry: 2014-01-15 09:50:51 UTC
[16-Nov-2013 15:20:54] OAuth client: Accessing the API call at https://graph.facebook.com/me?access_token=CAAG2RZAKZAvugBAI5bLM5Yin7SGtlXZBPkdSPXQ3pp7XLDNCM51G8ZAGXvK05v0n4FBqGyZC9j4hG9dNP9EGDkAFjDCcVQ92qhGlic2Kylelk58Vl6vQZCAvtQd81BisZAyl48WK22khlAOmksksXZBv2Rxnj05V6drMvZBGlPQJJYNiwryRsn8Lv
[16-Nov-2013 15:20:54] Connecting to graph.facebook.com
[16-Nov-2013 15:20:54] Resolving HTTP server domain "graph.facebook.com"...
[16-Nov-2013 15:20:54] Connecting to HTTP server IP 31.13.68.16 port 443...
[16-Nov-2013 15:20:55] Connected to graph.facebook.com
[16-Nov-2013 15:20:55] C GET /me?access_token=CAAG2RZAKZAvugBAI5bLM5Yin7SGtlXZBPkdSPXQ3pp7XLDNCM51G8ZAGXvK05v0n4FBqGyZC9j4hG9dNP9EGDkAFjDCcVQ92qhGlic2Kylelk58Vl6vQZCAvtQd81BisZAyl48WK22khlAOmksksXZBv2Rxnj05V6drMvZBGlPQJJYNiwryRsn8Lv HTTP/1.1
[16-Nov-2013 15:20:55] C Host: graph.facebook.com
[16-Nov-2013 15:20:55] C User-Agent: PHP-OAuth-API (http://www.phpclasses.org/oauth-api $Revision: 1.74 $)
[16-Nov-2013 15:20:55] C Accept: */*
[16-Nov-2013 15:20:55] C Connection: Keep-Alive
[16-Nov-2013 15:20:55] C
[16-Nov-2013 15:20:56] S HTTP/1.1 200 OK
[16-Nov-2013 15:20:56] S Access-Control-Allow-Origin: *
[16-Nov-2013 15:20:56] S Cache-Control: private, no-cache, no-store, must-revalidate
[16-Nov-2013 15:20:56] S Content-Type: application/json; charset=UTF-8
[16-Nov-2013 15:20:56] S ETag: "38d4788835f8705a6e573c117480e8b409e645fa"
[16-Nov-2013 15:20:56] S Expires: Sat, 01 Jan 2000 00:00:00 GMT
[16-Nov-2013 15:20:56] S Last-Modified: 2013-11-01T18:35:47+0000
[16-Nov-2013 15:20:56] S Pragma: no-cache
[16-Nov-2013 15:20:56] S X-FB-Rev: 1010817
[16-Nov-2013 15:20:56] S X-FB-Debug: Xf/c81dJ7VE7Q1k4f4X0N0de4wbFaIfnsZo+PylI4dg=
[16-Nov-2013 15:20:56] S Date: Sat, 16 Nov 2013 09:50:59 GMT
[16-Nov-2013 15:20:56] S Transfer-Encoding: chunked
[16-Nov-2013 15:20:56] S Connection: keep-alive
[16-Nov-2013 15:20:56] S
[16-Nov-2013 15:20:56] S 8b2
[16-Nov-2013 15:20:56] S
[16-Nov-2013 15:20:56] S 17f9
[16-Nov-2013 15:20:56] S
[16-Nov-2013 15:20:56] S
[16-Nov-2013 15:20:56] S
[16-Nov-2013 15:20:56] S
[16-Nov-2013 15:20:56] S 547
[16-Nov-2013 15:20:56] S
[16-Nov-2013 15:20:56] S bbf
[16-Nov-2013 15:20:56] S
[16-Nov-2013 15:20:56] S 35:47+0000"}
[16-Nov-2013 15:20:56] S 0
[16-Nov-2013 15:20:56] S
[16-Nov-2013 15:20:56] Keeping the connection alive to graph.facebook.com

  26. Re: PHP oAuth API   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-11-17 19:59:42 - In reply to message 25 from pradeep
You are not using a database access class like for instance mysqli_oauth_client_class.

It is important that you study the class and the examples so you are not trying things blindly and hope they can work.

I can help when it comes to using the class but I can study for you.

If you are not sure where to start take a look at the example mysqli_login_with_google.php .

  27. Re: PHP oAuth API   Reply   Report abuse  
Picture of pradeep pradeep - 2013-11-18 18:17:16 - In reply to message 26 from Manuel Lemos
i am stuck. dont know what to do to get my data to be entered into my database

  28. Re: PHP oAuth API   Reply   Report abuse  
Picture of E.F. de moor E.F. de moor - 2013-11-19 08:23:45 - In reply to message 24 from E.F. de moor
Manuel,

Did you already find time to test the code of message 22 of this thread?

Thanks a lot,

Ernst de Moor.

  29. PHP oAuth API   Reply   Report abuse  
Picture of Robinson Salgado Cevallos Robinson Salgado Cevallos - 2013-11-28 22:05:55 - In reply to message 2 from Manuel Lemos
Hello

Your code has been of great help. But I can not find how to revoke permissions for both facebook, google and twitter.

Might help me with some example code that is generic to effect revocation of permits with this API?

Thanks for your help

  30. Re: PHP oAuth API   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-11-29 01:24:26 - In reply to message 29 from Robinson Salgado Cevallos
There is not really a way to revoke permissions from the application site. Only the user can revoke application permissions.

What you can do is to "forget" the token that you have obtained. Just call ResetAccessToken.

I may write an article on this soon.

 
  1 - 10   11 - 20   21 - 30   31 - 31