I get this error whenever I try to post or get something, but the
connect its ok because I get the tokens, my code is

<?php
require_once(PK_APP_DIR . 'libs/twitteroauth/twitteroauth.php');

function twitterAction() {
        if (!empty($_GET['oauth_token'])) {
                $_SESSION['oauth_token'] = $_GET['oauth_token'];
                $_SESSION['oauth_verifier'] = $_GET['oauth_verifier'];
        }

        if (!empty($_SESSION['oauth_token'])) {
                twitterPost();
                return;
        }

        twitterLogin();

}

function twitterLogin() {
        $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);

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

        /* 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;
        }
}

function twitterPost() {
        $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
$access_token['oauth_token'], $access_token['oauth_token_secret']);

        $request_token = $connection->getRequestToken();

        $connection->token = $request_token;

        $user = $connection->get('account/verify_credentials');

        print_r($connection);
}

and the dump is

TwitterOAuth Object
(
    [http_code] => 401
    [url] =>
https://api.twitter.com/1/account/verify_credentials.json?oauth_consumer_key=------&oauth_nonce=------&oauth_signature=---------&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1291211074&oauth_token=&oauth_version=1.0
    [host] => https://api.twitter.com/1/
    [timeout] => 30
    [connecttimeout] => 30
    [ssl_verifypeer] =>
    [format] => json
    [decode_json] => 1
    [http_info] => Array
        (
            [url] =>
https://api.twitter.com/1/account/verify_credentials.json?oauth_consumer_key=---------&oauth_nonce=---------&oauth_signature=---------&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1291211074&oauth_token=&oauth_version=1.0
            [content_type] => application/json; charset=utf-8
            [http_code] => 401
            [header_size] => 826
            [request_size] => 354
            [filetime] => -1
            [ssl_verify_result] => 0
            [redirect_count] => 0
            [total_time] => 0.275773
            [namelookup_time] => 3.9E-05
            [connect_time] => 0.045649
            [pretransfer_time] => 0.171161
            [size_upload] => 0
            [size_download] => 317
            [speed_download] => 1149
            [speed_upload] => 0
            [download_content_length] => 317
            [upload_content_length] => 0
            [starttransfer_time] => 0.275766
            [redirect_time] => 0
        )

    [useragent] => TwitterOAuth v0.2.0-beta2
    [sha1_method] => OAuthSignatureMethod_HMAC_SHA1 Object
        (
        )

    [consumer] => OAuthConsumer Object
        (
            [key] => -----
            [secret] => -------
            [callback_url] =>
        )

    [token] => Array
        (
            [oauth_token] => -----
            [oauth_token_secret] => ------
        )

    [http_header] => Array
        (
            [date] => Wed, 01 Dec 2010 13:44:35 GMT
            [server] => hi
            [status] => 401 Unauthorized
            [x_transaction] => 1291211074-93502-34463
            [etag] => "8e0aebf98245ddc8f9eb18cce7cdde28"
            [last_modified] => Wed, 01 Dec 2010 13:44:34 GMT
            [x_runtime] => 0.00373
            [content_type] => application/json; charset=utf-8
            [content_length] => 317
            [pragma] => no-cache
            [x_revision] => DEV
            [expires] => Wed, 01 Dec 2010 13:49:35 GMT
            [cache_control] => no-cache, max-age=300
            [set_cookie] =>
_twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCKxuLaIsAToHaWQiJWFiNTkwZjNkMTNjNDc0%250ANDU4ZjZlMTEyNjY2YmYzOTA2IgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy
%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--
edc33251842d784d4e2904a39c46b76f82571354; domain=.twitter.com; path=/
            [vary] => Accept-Encoding
            [connection] => close
            [www_authenticate] => Basic realm="Twitter API"
        )

)


I change my tokens and keys with -------

-- 
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