Comments (11)
I'm not sure I understand your request. Could you please elaborate or give an example? Thank you in advance.
from sttwitter.
So, for example, take STTwitterOS implementation, scroll down to line #85.
Here you create an error and pass a code equal to '0':
- (void)verifyCredentialsWithSuccessBlock:(void(^)(NSString *username))successBlock errorBlock:(void(^)(NSError *error))errorBlock {
if([self hasAccessToTwitter] == NO) {
NSString *message = @"This system cannot access Twitter.";
NSError *error = [NSError errorWithDomain:NSStringFromClass([self class]) code:0 userInfo:@{NSLocalizedDescriptionKey : message}];
errorBlock(error);
return;
}
....
}
Idea is to create a special error code for every particular error in a particular domain.
You can define enum for every particular domain or one for the entire project:
typedef NS_ENUM(NSUInteger, STTwitterOSErrorCode) {
STTwitterOSErrorCodeCannotAccessTwitter, //This system cannot access Twitter.
//etc
};
And later you use a code with error and client, who received that error can be used to compare that code.
...
//Sending error
NSString *message = @"This system cannot access Twitter.";
NSError *error = [NSError errorWithDomain:NSStringFromClass([self class]) code:STTwitterOSErrorCodeCannotAccessTwitter userInfo:@{NSLocalizedDescriptionKey : message}];
errorBlock(error);
...
...
//Handling error
[_twitter verifyCredentialsWithSuccessBlock:^(NSString *username) {
_loginStatusLabel.text = username;
} errorBlock:^(NSError *error) {
if(error.code == STTwitterOSErrorCodeCannotAccessTwitter) {
//Do something special
}
}];
from sttwitter.
Thank you for this explanation. You're totally right. I'll add errors soon.
from sttwitter.
You are welcome, thanks for understanding.
from sttwitter.
from sttwitter.
Hello can you plz help me I'm using STTwitter and using this method for reverse authentication but i'm getting error like this
Error Domain=STTwitterOS Code=0 "This system cannot access Twitter." UserInfo=0xd8f05b0 {NSLocalizedDescription=This system cannot access Twitter.
here what I'm using
STTwitterAPI *twitter = [STTwitterAPI twitterAPIWithOAuthConsumerKey:TWITTER_CONSUMER_KEY
consumerSecret:TWITTER_CONSUMER_SECRET];
[twitter postReverseOAuthTokenRequest:^(NSString *authenticationHeader) {
STTwitterAPI *twitterAPIOS = [STTwitterAPI twitterAPIOSWithFirstAccount];
[twitterAPIOS verifyCredentialsWithSuccessBlock:^(NSString *username) {
[twitterAPIOS postReverseAuthAccessTokenWithAuthenticationHeader:authenticationHeader
successBlock:^(NSString *oAuthToken,
NSString *oAuthTokenSecret,
NSString *userID,
NSString *screenName) {
NSLog(@"oAuthToken: %@, oAuthTokenSecret: %@, userID: %@, screenName: %@", oAuthToken, oAuthTokenSecret, userID, screenName);
self.twAuthData = @{@"oAuthToken" : oAuthToken,
@"oAuthTokenSecret" : oAuthTokenSecret,
@"userID" : userID,
@"screenName" : screenName};
if ([self.twDelegate respondsToSelector:@selector(loginForNetwork:successful:needsRegistration:)]) {
[self.twDelegate loginForNetwork:kNetworkType_TW successful:YES needsRegistration:YES];
}
} errorBlock:^(NSError *error) {
NSLog(@"error %@", error);
}];
} errorBlock:^(NSError *error) {
NSLog(@"error %@", error);
}];
} errorBlock:^(NSError *error) {
NSLog(@"error %@", error);
}];
need your help
from sttwitter.
Are you sure there is a Twitter account set up in iOS Settings? (or OS X Preferences if you're on OS X)
from sttwitter.
Hi,
I am getting this error ERror: Error Domain=STTwitterTwitterErrorDomain Code=0 "not recognized." UserInfo=0x7b0c8d90 {NSLocalizedDescription=not recognized.} when I am trying to upload video.
I got Twitter account from my device settings.
Here is my code to upload video:
[_twitter postMediaUploadData:[NSData dataWithContentsOfFile:filePath] fileName:@"Test" uploadProgressBlock:^(NSInteger bytesWritten, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite) {
} successBlock:^(NSDictionary *imageDictionary, NSString *mediaID, NSString *size) {
NSLog(@"Image dictionary: %@", imageDictionary);
NSLog(@"Media ID; %@", mediaID);
NSLog(@"Size; %@", size);
} errorBlock:^(NSError *error) {
NSLog(@"ERror: %@",error);
}];
I am not sure if I am in correct path or not. Please let me know if anything wrong.
Thanks in Advance :)
from sttwitter.
From Twitter API documentation: "Currently, the only type exposed in our entities is photo". So I don't think you can upload videos.
from sttwitter.
Hi, I need your help. I'm trying different solutions for days :(
I sign in into twitter in my app, I have the authorization. And everything is OK. In that moment I save oAuthToken, oAuthTokenSecret, username... and all the info that I can with the purpose of don't ask again user for his username/password.
So the next time that user go into the app, I just want to post with the twitter's info that I have saved. But I can't "reconnect" or "reopen" the session.
Please, could anyone help me?? I'm really struggling :/
This is what I'm trying:
STTwitterAPI *twitter = [STTwitterAPI twitterAPIWithOAuthConsumerName:nil
consumerKey:@"xxx"
consumerSecret:@"xxx"];
[twitter postReverseOAuthTokenRequest:^(NSString *authenticationHeader) {
STTwitterAPI *twitterAPIOS = [STTwitterAPI twitterAPIOSWithFirstAccount];
[twitterAPIOS verifyCredentialsWithSuccessBlock:^(NSString *username) {
[twitterAPIOS postReverseAuthAccessTokenWithAuthenticationHeader:authenticationHeader
successBlock:^(NSString *oAuthToken,
NSString *oAuthTokenSecret,
NSString *userID,
NSString *screenName) {
// I'm trying to POST on twitter HERE
} errorBlock:^(NSError *error) {
NSLog(@"-- ERROR1: %@", error);
}];
} errorBlock:^(NSError *error) {
NSLog(@"-- ERROR2: %@", error);
}];
And the ERROR that I'm getting is the first one that I control:
ERROR1: Error Domain=STTwitterOS Code=0 "This system cannot access Twitter." UserInfo=0x14d06d30 {NSLocalizedDescription=This system cannot access Twitter.}
from sttwitter.
Well, I think that the wrong point is when I ask for twitterAPIOSWithFirstAccount. Because I haven't got twitter installed in my phone. So, How could I create an account from the saved info that I have of the first user's authentication??
Thank you in advance!
from sttwitter.
Related Issues (20)
- _getUserStreamStallWarning:... cancelling on receiving friends list?
- Attachment_url HOT 2
- postTokenRequest never callsback success or failure HOT 1
- Use of API only available in iOS 8
- Support for new events APIs HOT 1
- Modify character counter to take into account usernames at beginning of tweets HOT 1
- Carthage Support HOT 1
- STTwitter and iOS 11 HOT 2
- Twitter API request with JSON body HOT 2
- STTwitter in macOS 10.13 HOT 3
- Saving account to device settings HOT 1
- Perform video uploads from local NSData
- SLServiceTypeTwitter is deprecated in ios11 objc "SLServiceTypeTwitter' is deprecated: first deprecated in iOS 11.0"
- media_ids parameter is invalid.
- newest XCode throws warnings: This block declaration is not a prototype
- ⚠️ Legacy APIs must be migrated to new ones within 5 months! HOT 2
- Supporting “full_text” of a tweet with “tweet_mode=extended” HOT 1
- Twitter API 2.0
- How do I set up to jump to the Twitter App to sign in?
- Thread 1: "-[STTwitterAppOnly postTokenRequest:authenticateInsteadOfAuthorize:forceLogin:screenName:oauthCallback:errorBlock:]: unrecognized selector sent to instance 0x280371140" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sttwitter.