我正在尝试从Twitter上获取用户个人资料头像,但我无法这样做。
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)")
}
}
}
}
}
我一直在获取默认的Twitter用户信息。我做错了什么
{
"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/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" = "<null>";
"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 = "<null>";
coordinates = "<null>";
"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/aNbMsNNkoY";
}
);
"user_mentions" = (
);
};
"favorite_count" = 111;
favorited = 0;
geo = "<null>";
id = 692055909007282176;
"id_str" = 692055909007282176;
"in_reply_to_screen_name" = "<null>";
"in_reply_to_status_id" = "<null>";
"in_reply_to_status_id_str" = "<null>";
"in_reply_to_user_id" = "<null>";
"in_reply_to_user_id_str" = "<null>";
"is_quote_status" = 0;
lang = en;
place = "<null>";
"possibly_sensitive" = 0;
"retweet_count" = 99;
retweeted = 0;
source = "<a href=\"https://about.twitter.com/products/tweetdeck\" rel=\"nofollow\">TweetDeck</a>";
text = "As announced in 2013, we're completing retirement of our v1 APIs. See our post for timeline & migration information: https://t.co/aNbMsNNkoY";
truncated = 0;
};
"statuses_count" = 3556;
"time_zone" = "Pacific Time (US & Canada)";
url = "http://t.co/78pYTvWfJd";
"utc_offset" = "-28800";
verified = 1;
}
当我打印数据时,这就是我得到的。