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

  • SEARCH
  • Home
  • 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 8467041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:31:35+00:00 2026-06-10T15:31:35+00:00

oauth_token=requestkey&oauth_token_secret=requestsecret How can I use NSScanner to get requestkey and requestsecret. I can’t seem

  • 0
oauth_token=requestkey&oauth_token_secret=requestsecret

How can I use NSScanner to get “requestkey” and “requestsecret”. I can’t seem to achieve it.

NSScanner* scanner = [NSScanner scannerWithString:string];
NSString *oauth_token = @"oauth_token=";
NSString *oauth_token_secret = @"oauth_token_secret=";
[scanner setCharactersToBeSkipped:nil];

NSString *token;
NSString *key;


while (![scanner isAtEnd]) {
    [scanner scanString:oauth_token intoString:NULL];
    [scanner scanUpToCharactersFromSet:[NSCharacterSet characterSetWithCharactersInString:@"&"] intoString:&token];
    [scanner scanUpToString:oauth_token_secret intoString:NULL];
    [scanner scanUpToString:oauth_token intoString:&key];

    NSLog(@"token%@", token);
    NSLog(@"key %@", key);

//token requestkey
//key oauth_token_secret=requestsecret

}

I can’t seem to figure out why is it null. Thanks!

  • 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-10T15:31:36+00:00Added an answer on June 10, 2026 at 3:31 pm

    Nothing is null. So I can’t speak to that.

    It’s actually a pretty straight forward error if you just follow the logic of your code line by line. For example:

    [scanner scanString:oauth_token intoString:nil];
    // The cursor is now just after the equals sign.
    [scanner scanUpToCharactersFromSet:[NSCharacterSet characterSetWithCharactersInString:@"&"] intoString:&token];
    // This leaves the cursor just BEFORE the &.
    [scanner scanUpToString:oauth_token_secret intoString:nil];
    // This leaves the cursor just BEFORE the "oauth_token_secret="
    [scanner scanUpToString:oauth_token intoString:&key];
    // This scans effectively the rest of the string into &key which is in fact
    // "oauth_token_secret=requestsecret"
    

    The simplest way to fix this is to use the scanString:intoString: method to advance the cursor to the end of oauth_token_secret.

    [scanner scanString:oauth_token intoString:nil];
    [scanner scanUpToCharactersFromSet:[NSCharacterSet characterSetWithCharactersInString:@"&"] intoString:&token];
    [scanner scanUpToString:oauth_token_secret intoString:nil];
    // This leaves the cursor just BEFORE the "oauth_token_secret="
    
    // **FIX HERE**
    [scanner scanString:oauth_token_secret intoString:nil];
    // The cursor is now AFTER oauth_token_secret.
    
    [scanner scanUpToString:oauth_token intoString:&key];
    

    The log output now shows useful strings.

    token:requestkey
    key  :requestsecret
    

    But, as H2CO3 said in the comments section, componentsSeparatedByString: is a much better fit for this use case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this : oauth_token=1%2F7VDUGD4tKIqSu4jX4DoeCRD1KbqqgTxFnFFliVgbSss&oauth_token_secret=Rk%2FwejMIg6t%2BFphvRd%2BZ5Wkc How can I extract the two
I have the following String: oauth_token=safcanhpyuqu96vfhn4w6p9x&**oauth_token_secret=hVhzHVVMHySB**&application_name=Application_Name&login_url=https%3A%2F%2Fapi-user.netflix.com%2Foauth%2Flogin%3Foauth_token%3Dsafcanhpyuqu96vfhn4w6p9x I am trying to parse out the value
How can do I use: ' https://graph.facebook.com/ .$data[user_id].?access_token=.$data[oauth_token]' After the user accepts my application
Some OpenSocial containers use xoauth_security_token for signing requests, instead of oauth_token and oauth_token_secret .
After successfully acquiring an oauth_token for a user, I am able to get successful
I want use php curl with oauth to get the JSON data from twitter
I have the oauth_token and oauth_token_secret values stored in the database. Is it possible
I am working on the application where I have to get the subscriberid, oauth_token
I'm trying to use jTwitter to get an oauth instance to twitter with my
I am trying to get a Twitter oauth token using the below string. How

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.