Question

When trying to simply get mentions on an account that properly verifies I get the following JSON:

"mentions": {
    "errors": [
        {
        "message": "Sorry, that page does not exist",
        "code": 34
        }
    ]
},

The code that I'm using to log in and produce this is as follows:

private function get_twitter( $json ) {

    $_SESSION['access_token']['oauth_token'] = ACCESS_TOKEN;
    $_SESSION['access_token']['oauth_token_secret'] = ACCESS_TOKEN_SECRET;

    /* If access tokens are not available redirect to connect page. */
    if (empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret'])) {
        /* Load and clear sessions */
        session_start();
        session_destroy();
        if (CONSUMER_KEY === '' || CONSUMER_SECRET === '' || CONSUMER_KEY === 'CONSUMER_KEY_HERE' || CONSUMER_SECRET === 'CONSUMER_SECRET_HERE') {
          $json['twitter_login_prompt'] = 'You need a consumer key and secret. Get one from <a href="https://dev.twitter.com/apps">dev.twitter.com/apps</a>';
          exit;
        }

        /* Build an image link to start the redirect process. */
        $json['twitter_login'] = '<a href="./redirect.php"><img src="./images/lighter.png" alt="Sign in with Twitter"/></a>';
    }
    /* 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. */
        $json['twitter_verify'] = $connection->get('account/verify_credentials');
        $json['mentions'] = $connection->get('/1/statuses/mentions');
        return $json;
    }
Was it helpful?

Solution

The api version you're using has been deprecated https://dev.twitter.com/docs/api/1/get/statuses/mentions

Please consider moving to use of 1.1 version of Twitter API: https://dev.twitter.com/docs/api/1.1/get/statuses/mentions_timeline

You might want to use the following instruction instead:

$json['mentions'] = $connection->get('/1.1/statuses/mentions');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top