I have referred the demo FHSTwitterEngine for posting tweets in iOS.
To post a tweet with image I have used this method,
- (NSError *)postTweet:(NSString *)tweetString withImageData:(NSData *)theData
It fails with response.statusCode
as 403
.
The return data shows this message:
{"errors":[{"code":195,"message":"Missing or invalid url parameter"}]}
Parameters tweetString
and theData
passed are not nil
.
if i only post text as original,it's succeed.
What could be the issue? Any pointers?
https://github.com/fhsjaagshs/FHSTwitterEngine/blob/master/FHSTwitterEngine/FHSTwitterEngine.m
please, good luck!
====
I have referred the demo FHSTwitterEngine for posting tweets in iOS.
To post a tweet with image I have used this method,
The return data shows this message:
{"errors":[{"code":195,"message":"Missing or invalid url parameter"}]} Parameters tweetString and theData passed are not nil.
if i only post text as original,it's succeed.
What could be the issue? Any pointers?
Error say that you missed/invalid parameter of URL first check it? If make sure that you have to passed all required parameter. then convert your URL string as legal URL. such like,
NSString *urlString = [NSString stringWithFormat:@"URL_STRING"];
NSURL *myUrl = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
For more info about stringByAddingPercentEscapesUsingEncoding.
Try this for local image
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.png"];
NSData *ImageData;//= [NSData dataWithContentsOfURL:url];
UIImage *image = img.image;
ImageData=UIImagePNGRepresentation(image);
[ImageData writeToFile:savedImagePath atomically:NO];
if ([TxtField.text isEqualToString:@""]) {
[[TwitterEngine sharedManager]postTweet:@"This is test image" withImageData:ImageData];
}
else
[[TwitterEngine sharedManager]postTweet:TxtField.text withImageData:ImageData];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.