doudou201701 2010-05-02 16:24
浏览 24
已采纳

Codeigniter Twitter库:我的回调网址是什么。 我在哪里可以找到它?

I would like to know where i can find my callback url in ci? Im quite new to it so not really sure.

Here is the lib im using.

<?php

class Home extends Controller {

    function Home()
    {
        parent::Controller();   
    }

    public function index()
    {
        // This is how we do a basic auth:
        // $this->twitter->auth('user', 'password');

        // Fill in your twitter oauth client keys here

        $consumer_key = '';
        $consumer_key_secret = '';

        // For this example, we're going to get and save our access_token and access_token_secret
        // in session data, but you might want to use a database instead :)

        $this->load->library('session');

        $tokens['access_token'] = NULL;
        $tokens['access_token_secret'] = NULL;

        // GET THE ACCESS TOKENS

        $oauth_tokens = $this->session->userdata('twitter_oauth_tokens');

        if ( $oauth_tokens !== FALSE ) $tokens = $oauth_tokens;

        $this->load->library('twitter');

        $auth = $this->twitter->oauth($consumer_key, $consumer_key_secret, $tokens['access_token'], $tokens['access_token_secret']);

        if ( isset($auth['access_token']) && isset($auth['access_token_secret']) )
        {
            // SAVE THE ACCESS TOKENS

            $this->session->set_userdata('twitter_oauth_tokens', $auth);

            if ( isset($_GET['oauth_token']) )
            {
                $uri = $_SERVER['REQUEST_URI'];
                $parts = explode('?', $uri);

                // Now we redirect the user since we've saved their stuff!

                header('Location: '.$parts[0]);
                return;
            }
        }

        // This is where  you can call a method.

        $this->twitter->call('statuses/update', array('status' => 'Testing CI Twitter oAuth sexyness by @elliothaughin'));

        // Here's the calls you can make now.
        // Sexy!

        /*
        $this->twitter->call('statuses/friends_timeline');
        $this->twitter->search('search', array('q' => 'elliot'));
        $this->twitter->search('trends');
        $this->twitter->search('trends/current');
        $this->twitter->search('trends/daily');
        $this->twitter->search('trends/weekly');
        $this->twitter->call('statuses/public_timeline');
        $this->twitter->call('statuses/friends_timeline');
        $this->twitter->call('statuses/user_timeline');
        $this->twitter->call('statuses/show', array('id' => 1234));
        $this->twitter->call('direct_messages');
        $this->twitter->call('statuses/update', array('status' => 'If this tweet appears, oAuth is working!'));
        $this->twitter->call('statuses/destroy', array('id' => 1234));
        $this->twitter->call('users/show', array('id' => 'elliothaughin'));
        $this->twitter->call('statuses/friends', array('id' => 'elliothaughin'));
        $this->twitter->call('statuses/followers', array('id' => 'elliothaughin'));
        $this->twitter->call('direct_messages');
        $this->twitter->call('direct_messages/sent');
        $this->twitter->call('direct_messages/new', array('user' => 'jamierumbelow', 'text' => 'This is a library test. Ignore'));
        $this->twitter->call('direct_messages/destroy', array('id' => 123));
        $this->twitter->call('friendships/create', array('id' => 'elliothaughin'));
        $this->twitter->call('friendships/destroy', array('id' => 123));
        $this->twitter->call('friendships/exists', array('user_a' => 'elliothaughin', 'user_b' => 'jamierumbelow'));
        $this->twitter->call('account/verify_credentials');
        $this->twitter->call('account/rate_limit_status');
        $this->twitter->call('account/rate_limit_status');
        $this->twitter->call('account/update_delivery_device', array('device' => 'none'));
        $this->twitter->call('account/update_profile_colors', array('profile_text_color' => '666666'));
        $this->twitter->call('help/test');
        */
    }
}

/* End of file welcome.php */
/* Location: ./system/application/controllers/home.php */

Thank you all

  • 写回答

2条回答 默认 最新

  • douluanji8752 2010-05-03 09:36
    关注

    Ok, I found the solution!

    The problem was in the .htaccess file I'm using (to remove the index.php from the url)

    I changed RewriteRule ^(.)$ /index.php?/$1 [L] to RewriteRule ^(.)$ /index.php/$1 [L] and now is working. I found that in a comment in this link: http://www.askaboutphp.com/58/codeigniter-mixing-segment-based-url-with-querystrings.html

    If someone needs more information, just let me know.

    Luis

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区