Skip to content
This repository has been archived by the owner on Oct 5, 2019. It is now read-only.

Access periscope API failed #117

Open
XiaoDongXie1024 opened this issue Apr 25, 2019 · 0 comments
Open

Access periscope API failed #117

XiaoDongXie1024 opened this issue Apr 25, 2019 · 0 comments

Comments

@XiaoDongXie1024
Copy link

XiaoDongXie1024 commented Apr 25, 2019

I try to access "https://api.periscope.tv/api/v2/loginTwitter" by sendTwitterRequest after login but the response is 400. I'm sure my token,secret is correct. what should I do?

#define kPeriscopeParaLoginSession           @"session_key"
#define kPeriscopeParaLoginSessionSecret     @"session_secret"
#define kPeriscopeParaLoginUserId            @"user_id"
#define kPeriscopeParaLoginUserName          @"user_name"

    TWTRLogInButton *logInButton = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession *session, NSError *error) {
        if (session) {
            NSLog(@"signed in as token:%@,secret:%@,user:%@,Id:%@", session.authToken, session.authTokenSecret, session.userName, session.userID);
            
            NSDictionary *dic = @{
                                  kPeriscopeParaLoginSession        : session.authToken,
                                  kPeriscopeParaLoginSessionSecret  : session.authTokenSecret,
                                  kPeriscopeParaLoginUserId         : session.userID,
                                  kPeriscopeParaLoginUserName       : session.userName,
                                  };
            TWTRAPIClient *client = [TWTRAPIClient clientWithCurrentUser];
            NSString *statusesShowEndpoint = @"https://api.periscope.tv/api/v2/loginTwitter";
        
            NSError *clientError;
            NSURLRequest *request =  [client URLRequestWithMethod:@"POST" URLString:statusesShowEndpoint parameters:dic error:&clientError];
            if (request) {
                [client sendTwitterRequest:request completion:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
                    if (data) {
                        // handle the response data e.g.
                        NSDictionary * dict = [self JSONObjectWithData:data options:kNilOptions error:NULL];
                        NSLog(@"data%@,dict:%@, error code:%ld,%@",data, dict,(long)error.code,error.localizedDescription);
                        if(dict)
                        {
                            self.loginResponseDic  = dict;
                            self.sessionToken      = session.authToken;
                            self.sessionSecret     = session.authTokenSecret;
                            self.cookie            = [self.loginResponseDic objectForKey:kPeriscopeParaCookie];
                        }
                    }
                    else {
                        NSLog(@"Error: %@", connectionError);
                    }
                }];
            }
            else {
                NSLog(@"Error: %@", clientError);
            }
        } else {
            NSLog(@"error: %@", [error localizedDescription]);
        }
    }];
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant