从任何 URL 获取特定图像,就像 Facebook 那样
Get a specific image from any URL like Facebook does
我的问题可能看起来与其他问题相似,但实际上并非如此。(据我所知)。我无法理解如何从任何 URL 中获取特定图像,就像 Facebook 那样,我无法向您展示屏幕截图,因为我没有真实的设备。但我可以向您展示从 MAC 截取的 Skype 屏幕截图。任何帮助将不胜感激。谢谢。
编辑:
我用这个 link 得到了图标,但它很小我想要更大的尺寸。
终于,我得到了答案。这可能对你有帮助,这就是为什么我 post 这个答案。
使用这个宏
#define FACEBOOK_GRAPH @"https://graph.facebook.com/v2.3/oauth/access_token?client_id=USE_YOUR_CLIENT_ID&client_secret=USE_YOUR_CLIENT_SECRET&grant_type=client_credentials"
注意: 您可以通过在 developer.facebook.com
上注册您的应用程序来获得 "client_id" 和 "client_secret" 现在拨打 FACEBOOK_GRAPH
点赞。
AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager];
//manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer=[AFJSONResponseSerializer new];
AFHTTPRequestOperation* operation = [manager POST:FACEBOOK_GRAPH parameters:nil
success:^(AFHTTPRequestOperation* op, id responseObject){
//here pass your URL as a string and access Token as a string, access token will found in responseObject
}
failure:^(AFHTTPRequestOperation* op, NSError* error){
NSLog(@"\n\nerror--->%@\n\n",error.localizedDescription);
}];
[operation start];
现在是从我们的 URL 获取图像的第二种方法,使用我们的 URL 并访问从上述方法
获取的令牌
url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
token = [token stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer=[AFJSONResponseSerializer new];
AFHTTPRequestOperation* operation = [manager POST:[NSString stringWithFormat:@"https://graph.facebook.com/v2.3/?id=%@&access_token=%@&scrape=true",url,token] parameters:nil success:^(AFHTTPRequestOperation* op, id responseObject){
NSLog(@"\n\nData Response==\n%@\n",responseObject);
//you will get Image URL in response
}failure:^(AFHTTPRequestOperation* op, NSError* error){
NSLog(@"##error--->\n%@",error.localizedDescription);
}];
[operation start];
我的问题可能看起来与其他问题相似,但实际上并非如此。(据我所知)。我无法理解如何从任何 URL 中获取特定图像,就像 Facebook 那样,我无法向您展示屏幕截图,因为我没有真实的设备。但我可以向您展示从 MAC 截取的 Skype 屏幕截图。任何帮助将不胜感激。谢谢。
编辑:
我用这个 link 得到了图标,但它很小我想要更大的尺寸。
终于,我得到了答案。这可能对你有帮助,这就是为什么我 post 这个答案。
使用这个宏#define FACEBOOK_GRAPH @"https://graph.facebook.com/v2.3/oauth/access_token?client_id=USE_YOUR_CLIENT_ID&client_secret=USE_YOUR_CLIENT_SECRET&grant_type=client_credentials"
注意: 您可以通过在 developer.facebook.com
上注册您的应用程序来获得 "client_id" 和 "client_secret" 现在拨打 FACEBOOK_GRAPH
点赞。
AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager];
//manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer=[AFJSONResponseSerializer new];
AFHTTPRequestOperation* operation = [manager POST:FACEBOOK_GRAPH parameters:nil
success:^(AFHTTPRequestOperation* op, id responseObject){
//here pass your URL as a string and access Token as a string, access token will found in responseObject
}
failure:^(AFHTTPRequestOperation* op, NSError* error){
NSLog(@"\n\nerror--->%@\n\n",error.localizedDescription);
}];
[operation start];
现在是从我们的 URL 获取图像的第二种方法,使用我们的 URL 并访问从上述方法
url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
token = [token stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer=[AFJSONResponseSerializer new];
AFHTTPRequestOperation* operation = [manager POST:[NSString stringWithFormat:@"https://graph.facebook.com/v2.3/?id=%@&access_token=%@&scrape=true",url,token] parameters:nil success:^(AFHTTPRequestOperation* op, id responseObject){
NSLog(@"\n\nData Response==\n%@\n",responseObject);
//you will get Image URL in response
}failure:^(AFHTTPRequestOperation* op, NSError* error){
NSLog(@"##error--->\n%@",error.localizedDescription);
}];
[operation start];