从Facebook这样的任何URL获取特定图像 [英] Get a specific image from any URL like Facebook does

查看:102
本文介绍了从Facebook这样的任何URL获取特定图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题看起来可能与其他问题类似,但事实并非如此。(根据我的知识)。我无法理解如何从任何URL获取特定图像像Facebook一样,我无法向您显示屏幕截图,因为我没有真正的设备。但我可以告诉你Skype的屏幕截图来自MAC。任何帮助将不胜感激。谢谢。

编辑:
我使用这个获得了favicon 链接但它非常小我想要更大的尺寸。

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.

i got favicon using this link but it is very small i want that in bigger size.

推荐答案

最后,我得到了答案。这可能对你有帮助,这就是为什么我发布这个答案。
使用这个宏
#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
注意:您可以通过以下方式获取client_id和client_secret在developer.facebook.com上注册您的应用程序
现在打电话给 FACEBOOK_GRAPH 如下所示。

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

这篇关于从Facebook这样的任何URL获取特定图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆