Currently using Fabric to request a tweet object using statuses/show API.
Here my code:
TWTRAPIClient *client = [[TWTRAPIClient alloc] init]; // guest context
// NSString *userID = [Twitter sharedInstance].sessionStore.session.userID;
// TWTRAPIClient *client = [[TWTRAPIClient alloc] initWithUserID:userID];
NSString *statusesShowEndpoint = @"https://api.twitter.com/1.1/statuses/show.json";
NSDictionary *params = @{@"id" : idstr};
NSError *clientError;
NSURLRequest *request = [client URLRequestWithMethod:@"GET" URL:statusesShowEndpoint parameters:params error:&clientError];
if (request) {
[client sendTwitterRequest:request completion:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if (data) {
// handle the response data e.g.
NSError *jsonError;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError];
NSLog(@"errorjson %@", jsonError);
NSLog(@"response %@", response);
NSLog(@"json %@", json);
}
else {
NSLog(@"Error: %@", connectionError);
}
}];
}
else {
NSLog(@"Error: %@", clientError);
}
idstr is the tweet id that was retrieved in another function. As I tested this, the id is “674388146075779072”
Just a random tweet with a GIF image in it.
The reply I get from twitter is weird because all of them (response, and data itself) is being cut into half.
RESPONSE:
{ status code: 200, headers {
“Cache-Control” = “no-cache, no-store, must-revalidate, pre-check=0, post-check=0”;
“Content-Disposition” = “attachment; filename=json.json”;
“Content-Encoding” = gzip;
“Content-Length” = 1385;
“Content-Type” = “application/json;charset=utf-8”;
Date = “Sat, 24 Dec 2016 03:02:43 GMT”;
Expires = “Tue, 31 Mar 1981 05:00:00 GMT”;
“Last-Modified” = “Sat, 24 Dec 2016 03:02:43 GMT”;
Pragma = “no-cache”;
Server = “tsa_k”;
Status = “200 OK”;
“Strict-Transport-Security” = “max-age=631138519”;
“x-access-level” = read;
“x-connection-hash” = a2cf0652fa095c3453a696e0607630fa;
“x-content-type-options” = nosniff;
“x-frame-options” = SAMEORIGIN;
“x-rate-limit-limit” = 900;
“x-rate-limit-remaining” = 899;
“x-rate-limit-reset” = 1482549463;
“x-response-time” = 246;
“x-transaction” = 009ea72700d9d60f;
" <-- cut off here.
And the DATA too:
json {
contributors = "<null>";
coordinates = "<null>";
"created_at" = "Wed Dec 09 00:40:38 +0000 2015";
entities = {
hashtags = (
);
media = (
{
"display_url" = "pic.twitter.com/HKngQYxjmC";
"expanded_url" = "https://twitter.com/bonerman_inc/status/674388146075779072/photo/1";
id = 674388065557725184;
"id_str" = 674388065557725184;
indices = (
50,
73
);
"media_url" = "http://pbs.twimg.com/tweet_video_thumb/CVvoX2BUwAA38oF.png";
"media_url_https" = "https://pbs.twimg.com/tweet_video_thumb/CVvoX2BUwAA38oF.png";
sizes = {
large = {
h = 429;
resize = fit;
w = 477;
};
mediu **<-- cut off here**
I am testing on my device iPhone6 with iOS10.0.1. Both with LTE mobile data and WiFi connection yields same result.
I have no idea why this is happening hope somebody can help shed some light what could be the cause of this.
EDIT: I just tested on Simulator iOS10, it works nicely. Seems only being cut off in my device! This is just weird.
EDIT2: It seems to be unrelated to device/simulator. It seems to be related to tweet IDs. Some tweet IDs give full replies, but for some the reply is truncated.
Working Tweet IDs:
812209211144884224
Tweet IDs that ended up cutting the reply:
812399587021438977
Hope someone can help me with this. No idea why it works for one tweet ID but not the other.