Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9112507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:45:07+00:00 2026-06-17T03:45:07+00:00

I have an app which links twitter to it with the API, in this

  • 0

I have an app which links twitter to it with the API, in this action I have a creation of a request key which is done here:

 public function createRequestKey()
 {
     $this->setScenario(self::SCENARIO_DEFAULT);
     if (!$this->validate())
         return false;

     $cache = \Yii::app()->cache;
     $key = __CLASS__ . '_' . $this->user->id . '_' . time() . '_' . rand(0, 100);
     $key = sha1($key);
     $data = array(
         'userId' => $this->user->id,      
     );
     $cache->set($key, $data, 60 * 30);
     $this->requestKey = $key;
     return true;
 }

The action that calls this method is this:

 public function actionTwitterLinkUrl()
 {
    if (!$this->checkOAuthRequest())
        return;

    $request  = \Yii::app()->getRequest();
    $response = \Yii::app()->response->setContentTypeToJSON();

    $user = $this->getUserFromHeader();
    $this->matchUserToLastValidatedToken($user);

    $linker = new \Sakanade\Operations\APITwitterLinker($user);
    if ($linker->createRequestKey()) {
        $params = $this->createQueryStringParams($linker->requestKey);
        $response->set('type',UserProfile::profileTypeToString(UserProfile::PROFILETYPE_TWITTER))
                 ->set('url', $request->getBaseUrl(true) . '/users/' . urlencode($user->id)
                 . '/profiles/twitter/link?' . http_build_query($params));
    } else {
        $response->setStatusCode(\Harusame\Components\HttpResponse::STATUS_BAD_REQUEST)
                 ->addMessage(\Sakanade\Models\Model::flattenErrorMessages($linker));
    }

    $response->render();
 }

But upon calling the next action, if I access the cache using $cache->get($key) it returns to false, even though it set the cache’s storage time of about 1800 seconds.

public function actionTwitterRunLink()
{
    $request = \Yii::app()->request;
    $requestKey = $request->getQuery('key');
    if (!$this->checkOAuthRequest())
        return;

    $user = $this->getUserFromHeader();
    $this->matchUserToLastValidatedToken($user);

    $authUrl = $this->getAuthorizationUrl($user);
    $response = \Yii::app()->response->setContentTypeToJSON();
    $cache = \Yii::app()->cache;
    $response->set('key', $cache->get($requestKey))
             ->set('key2', $requestKey);
    $response->render();
}

Upon displaying the rendered key from the cache it returns to false but if I try to get it from the previous action there is a returned value. Why is the cache cleared upon calling another action? Any help will be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T03:45:08+00:00Added an answer on June 17, 2026 at 3:45 am

    If im not mistaken cache time if not referenced from ‘now’
    I think it should be :

    $cache->set($key, $data, time() + (60 * 30));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a app which will download a file from web. The download action
I have an android app through which I can successfully update the twitter status.
I have a VBScript app which create Symbolic Links. Set wshell = CreateObject(WScript.Shell) .....
I have written a small app which links against libraries released under the LGPL.
I am currently working on app which is supposed to have Twitter integration. The
I have an app which costs $5. I'd like to change this so that
I have an app out which displays this link in a web view when
I have an iPhone app where I have many links which allows user to
I have written an app in C which expects two lines at input. First
I have this link which i need to translate in a php variable. http://www.facebook.com/dialog/apprequests?app_id=346824075388300&to=1149862205&message=Facebook+Dialogs+are+so+easy%21&redirect_uri=http%3A%2F%2Fpenelope-ns.net%2Ffb%2F

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.