~thielmann/+junk/noserub-webfinger

« back to all changes in this revision

Viewing changes to app/plugins/api/controllers/statuses_controller.php

  • Committer: dhofstet
  • Date: 2009-09-10 05:34:12 UTC
  • Revision ID: svn-v3-trunk0:ae07c2c2-3635-0410-bec2-e7f8933db683:branches%2Fdevelopment:1841
Enabling basic authentication for api/statuses/friends_timeline

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
2
/* Part of the twitter-compatible API */
3
3
class StatusesController extends ApiAppController {
4
 
        public $components = array('OauthServiceProvider', 'Responder');
 
4
        public $components = array('OauthServiceProvider', 'Responder', 'Security');
5
5
        const DEFAULT_LIMIT = 20;
6
6
        const MAX_LIMIT = 200;
7
7
        
18
18
        }
19
19
        
20
20
        public function friends_timeline() {
21
 
                $key = $this->OauthServiceProvider->getAccessTokenKeyOrDie();
22
 
                $accessToken = ClassRegistry::init('AccessToken');
23
 
                $identity_id = $accessToken->field('identity_id', array('token_key' => $key));
 
21
                $credentials = $this->Security->loginCredentials('basic');
 
22
                
 
23
                if ($credentials) {
 
24
                        $this->loadModel('ApiUser');
 
25
                        $identity_id = $this->ApiUser->getIdentityId($credentials['username'], $credentials['password']);
 
26
                        
 
27
                        if (!$identity_id) {
 
28
                                $this->Responder->respondWithNotAuthorized();
 
29
                                return;
 
30
                        }
 
31
                } else {
 
32
                        $key = $this->OauthServiceProvider->getAccessTokenKeyOrDie();
 
33
                        $accessToken = ClassRegistry::init('AccessToken');
 
34
                        $identity_id = $accessToken->field('identity_id', array('token_key' => $key));
 
35
                }
24
36
                
25
37
                $this->loadModel('Contact');
26
38