TrivialOAuthDataStore.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * A Trivial memory-based store - no support for tokens
  4. */
  5. class TrivialOAuthDataStore extends OAuthDataStore {
  6. private $consumers = array();
  7. function add_consumer($consumer_key, $consumer_secret) {
  8. $this->consumers[$consumer_key] = $consumer_secret;
  9. }
  10. function lookup_consumer($consumer_key) {
  11. if ( strpos($consumer_key, "http://" ) === 0 ) {
  12. $consumer = new OAuthConsumer($consumer_key,"secret", NULL);
  13. return $consumer;
  14. }
  15. if ( $this->consumers[$consumer_key] ) {
  16. $consumer = new OAuthConsumer($consumer_key,$this->consumers[$consumer_key], NULL);
  17. return $consumer;
  18. }
  19. return NULL;
  20. }
  21. function lookup_token($consumer, $token_type, $token) {
  22. return new OAuthToken($consumer, "");
  23. }
  24. // Return NULL if the nonce has not been used
  25. // Return $nonce if the nonce was previously used
  26. function lookup_nonce($consumer, $token, $nonce, $timestamp) {
  27. // Should add some clever logic to keep nonces from
  28. // being reused - for no we are really trusting
  29. // that the timestamp will save us
  30. return NULL;
  31. }
  32. function new_request_token($consumer) {
  33. return NULL;
  34. }
  35. function new_access_token($token, $consumer) {
  36. return NULL;
  37. }
  38. }
  39. ?>