Get a specific image from any URL like Facebook does

心不动则不痛 提交于 2019-12-12 07:58:32

问题


My Question might be looks like similar to other questions but really this is not.(according to my knowledge). i can't understand that how to fetch a specific image from any URL Like Facebook does, i can't show you screen shot because i don't have real device. but i can show you Skype's screen shot taken from MAC. any help will be appreciated. thanks.
EDIT:
i got favicon using this link but it is very small i want that in bigger size.


回答1:


finally, i got the answer. this might be helpful to you thats why i post this answer.
use this macro
#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"
NOTE: you can get "client_id" and "client_secret" by registering your Application on developer.facebook.com
now make a call for FACEBOOK_GRAPH Like bellow.

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];

now the second method to get image from our URL, use our URL and access Token got from above method

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];


来源:https://stackoverflow.com/questions/31851482/get-a-specific-image-from-any-url-like-facebook-does

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!