Запрос Twitter API для изображения профиля пользователя SwiftIOS

Программируем под IOS
Ответить
Anonymous
 Запрос Twitter API для изображения профиля пользователя Swift

Сообщение Anonymous »

Я пытаюсь получить аватар профиля пользователя из Твиттера после того, как он войдет в систему, но у меня возникли проблемы с этим.

Код: Выделить всё

   Twitter.sharedInstance().logInWithCompletion { session, error in
if (session != nil) {
if let userID = Twitter.sharedInstance().sessionStore.session()!.userID {
let client = TWTRAPIClient(userID: userID)
print("the user id is \(userID)")
let statusesShowEndpoint = "https://api.twitter.com/1.1/users/show.json?user_id=\(userID)"
let params = ["profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1438634086\/avatar_normal.png"]
var clientError : NSError?

let request = Twitter.sharedInstance().APIClient.URLRequestWithMethod("GET", URL: statusesShowEndpoint, parameters: params, error: &clientError)

client.sendTwitterRequest(request) { (response, data, connectionError) -> Void in
if (connectionError == nil) {
var jsonError : NSError?

do {
if let jsonResult = try NSJSONSerialization.JSONObjectWithData(data!, options: []) as? NSDictionary {
print("i am getting some form of data")
print(jsonResult)
}
} catch let error as NSError {
print(error.localizedDescription)
}

}
else {
print("Error: \(connectionError)")
}
}
}
}
}
Я продолжаю получать информацию о пользователях Твиттера по умолчанию. Что я делаю не так?

Код: Выделить всё

 {
"contributors_enabled" = 0;
"created_at" = "Wed May 23 06:01:13 +0000 2007";
"default_profile" = 0;
"default_profile_image" = 0;
description = "The Real Twitter API. I tweet about API changes, service issues and happily answer questions about Twitter and our API.  Don't get an answer? It's on my website.";
entities =     {
description =         {
urls =             (
);
};
url =         {
urls =             (
{
"display_url" = "dev.twitter.com";
"expanded_url" = "http://dev.twitter.com";
indices =                     (
0,
22
);
url = "http://t.co.example.com/78pYTvWfJd";
}
);
};
};
"favourites_count" = 27;
"follow_request_sent" = 0;
"followers_count" = 5561880;
following = 0;
"friends_count" = 47;
"geo_enabled" = 1;
"has_extended_profile" = 0;
id = 6253282;
"id_str" = 6253282;
"is_translation_enabled" = 0;
"is_translator" = 0;
lang = en;
"listed_count" = 13026;
location = "San Francisco, CA";
name = "Twitter API";
notifications = 0;
"profile_background_color" = C0DEED;
"profile_background_image_url" = "http://pbs.twimg.com/profile_background_images/656927849/miyt9dpjz77sc0w3d4vj.png";
"profile_background_image_url_https" = "https://pbs.twimg.com/profile_background_images/656927849/miyt9dpjz77sc0w3d4vj.png";
"profile_background_tile" = 1;
"profile_banner_url" = "https://pbs.twimg.com/profile_banners/6253282/1431474710";
"profile_image_url" = "http://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_normal.png";
"profile_image_url_https" = "https://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_normal.png";
"profile_link_color" = 0084B4;
"profile_location" = "";
"profile_sidebar_border_color" = C0DEED;
"profile_sidebar_fill_color" = DDEEF6;
"profile_text_color" = 333333;
"profile_use_background_image" = 1;
protected = 0;
"screen_name" = twitterapi;
status =     {
contributors = "";
coordinates = "";
"created_at" = "Tue Jan 26 18:46:01 +0000 2016";
entities =         {
hashtags =             (
);
symbols =             (
);
urls =             (
{
"display_url" = "twittercommunity.com/t/retiring-old\U2026";
"expanded_url" = "https://twittercommunity.com/t/retiring-old-v1-streaming-api-endpoints-on-march-31st-2016/60351";
indices =                     (
121,
144
);
url = "https://t.co.example.com/aNbMsNNkoY";
}
);
"user_mentions" =             (
);
};
"favorite_count" = 111;
favorited = 0;
geo = "";
id = 692055909007282176;
"id_str" = 692055909007282176;
"in_reply_to_screen_name" = "";
"in_reply_to_status_id" = "";
"in_reply_to_status_id_str" = "";
"in_reply_to_user_id" = "";
"in_reply_to_user_id_str" = "";
"is_quote_status" = 0;
lang = en;
place = "";
"possibly_sensitive" = 0;
"retweet_count" = 99;
retweeted = 0;
source = "[url=\]TweetDeck[/url]";
text = "As announced in 2013, we're completing retirement of our v1 APIs. See our post for timeline & migration information: https://t.co.example.com/aNbMsNNkoY";
truncated = 0;
};
"statuses_count" = 3556;
"time_zone" = "Pacific Time (US & Canada)";
url = "http://t.co.example.com/78pYTvWfJd";
"utc_offset" = "-28800";
verified = 1;
}
Когда я распечатываю данные, я получаю вот что.

Подробнее здесь: https://stackoverflow.com/questions/354 ... mage-swift
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «IOS»