Hi
         i am using the below code
        but it is still showing me error for authentication
        but user credential call is working fine.

              define('CONSUMER_KEY', $param['CONSUMER_KEY']);
                define('CONSUMER_SECRET',$param['CONSUMER_SECRET']);
                define('OAUTH_CALLBACK', $param['OAUTH_CALLBACK']);


                if(!isset($_SESSION['oauth_token']) ||
empty($_SESSION['oauth_token'])){
                        /* Build TwitterOAuth object with client credentials. */
                        $connection = new TwitterOAuth(CONSUMER_KEY, 
CONSUMER_SECRET);

                        /* Get temporary credentials. */
                        $request_token = 
$connection->getRequestToken(OAUTH_CALLBACK);

                        /* Save temporary credentials to session. */
                        $_SESSION['oauth_token'] = $token = 
$request_token['oauth_token'];
                        $_SESSION['oauth_token_secret'] =
$request_token['oauth_token_secret'];

                        /* If last connection failed don't display 
authorization link. */
                        switch ($connection->http_code) {
                          case 200:
                                /* Build authorize URL and redirect user to 
Twitter. */
                                $url = $connection->getAuthorizeURL($token);
                                header('Location: ' . $url);

                                break;
                          default:
                                /* Show notification if something went wrong. */
                                echo 'Could not connect to Twitter. Refresh the 
page or try again
later.';
                        }
                }

                
//////////////////////////////////////////////////////////////////////////////
                /* Create TwitteroAuth object with app key/secret and token key/
secret from default phase */
                $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
$_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);

                /* Request access tokens from twitter */
                $access_token = $connection-
>getAccessToken($_REQUEST['oauth_verifier']);

                /* Save the access tokens. Normally these would be saved in a
database for future use. */
                $_SESSION['access_token'] = $access_token;



                /* If HTTP response is 200 continue otherwise send to connect 
page
to retry */
                if (200 == $connection->http_code) {

                        /* The user has been verified and the access tokens can 
be saved
for future use */
                        $_SESSION['status'] = 'verified';

                        /* Get user access tokens out of the session. */
                        $access_token = $_SESSION['access_token'];

                        /* Create a TwitterOauth object with consumer/user 
tokens. */
                        $connection = new TwitterOAuth(CONSUMER_KEY, 
CONSUMER_SECRET,
$access_token['oauth_token'], $access_token['oauth_token_secret']);

                        /* If method is set change API call made. Test is 
called by
default. */
                        $content = 
$connection->get('account/verify_credentials');

                // Twitter re tweet api call
               $api = 'http://api.twitter.com/1/statuses/
retweets_of_me.json';
                // request twitter follower api
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, $api);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                $content= curl_exec($ch);
                curl_close($ch);

                 print_r($content);

                        session_destroy();

                        return $content;

                } else {

                         /* Save HTTP status for error dialog on connnect 
page.*/
                        if($this->debug){
                                echo $connection->http_code. ' invalid response 
code. <br/>';
                        }
                        return false;
                }

On Mar 22, 1:18 pm, CWorster <cwors...@schlimmer.com> wrote:
> Here are some OAuth Libraries in 
> PHPhttp://dev.twitter.com/pages/oauth_libraries#php
>
> 2011/3/22 deepak <deepak.d...@gmail.com>:
>
> > Hi,
>
> > We are displaying twitter latest 20 tweets to me on my website.
> > but this api call requires authorization and we have not found any
> > code for authorization using php.
>
> > we have read the full documentation of oauth on dev.twitter.com but
> > still when we access
> >http://api.twitter.com/1/statuses/retweets_to_me.json
>
> > it shows error message {"request":"\/1\/statuses\/retweets_of_me.json?
> > count=100&page=1&trim_user=true&include_entities=true","error":"Could
> > not authenticate you."}.
>
> > Please provide authorization code for api call.
>
> > Please help me to solve this issue.
>
> > Thanks
>
> > --
> > Twitter developer documentation and resources:http://dev.twitter.com/doc
> > API updates via Twitter:http://twitter.com/twitterapi
> > Issues/Enhancements Tracker:http://code.google.com/p/twitter-api/issues/list
> > Change your membership to this 
> > group:http://groups.google.com/group/twitter-development-talk

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk

Reply via email to