Objective c 如何使用instagram登录并使用IOS共享instagram?目标c
1)注册到InstagramObjective c 如何使用instagram登录并使用IOS共享instagram?目标c,objective-c,Objective C,1)注册到Instagram 要使用Instagram API创建应用程序,您必须拥有Instagram的帐户 在Instagram中创建帐户后,使用Instagram帐户登录并打开URL: 转到“注册您的应用程序”并单击“注册新客户端”按钮 您将被要求提供应用程序名称、应用程序描述、网站和oAuth重定向url。在这里,oAuth redirect_url指定在用户选择是否对应用程序进行身份验证后重定向用户的位置 成功注册新客户后,Instagram将提供客户ID、客户机密、网站URL、重定
- 要使用Instagram API创建应用程序,您必须拥有Instagram的帐户
- 在Instagram中创建帐户后,使用Instagram帐户登录并打开URL: 转到“注册您的应用程序”并单击“注册新客户端”按钮
- 您将被要求提供应用程序名称、应用程序描述、网站和oAuth重定向url。在这里,oAuth redirect_url指定在用户选择是否对应用程序进行身份验证后重定向用户的位置
- 成功注册新客户后,Instagram将提供客户ID、客户机密、网站URL、重定向URI等客户信息。保存客户端ID、客户端机密,将URI重定向到应用程序常量类,因为您需要它来验证Instagram
Add a file in your project
Provide the file name is
首先设置身份验证URL
#ifndef ConstantHandler_h
#define ConstantHandler_h
//set User authentication and url
#define INSTAGRAM_AUTHURL @"https://api.instagram.com/oauth/authorize/"
#define INSTAGRAM_APIURl @"https://api.instagram.com/v1/users/"
#define INSTAGRAM_CLIENT_ID @"Client Id"
#define INSTAGRAM_CLIENTSERCRET @"Clients Secret"
#define INSTAGRAM_REDIRECT_URL @"Redirect URL"
#define INSTAGRAM_ACCESS_TOKEN @"access_token"
#define INSTAGRAM_SCOPE @"likes+comments+relationships+basic"
//Contant Url
#define ACCESS_TOKEN @"#access_token="
#define UNSIGNED @"UNSIGNED"
#define CODE @"code="
#define END_POINT_URL @"https://api.instagram.com/oauth/access_token"
#define HTTP_METHOD @"POST"
#define CONTENT_LENGTH @"Content-Length"
#define REQUEST_DATA @"application/x-www-form-urlencoded"
#define CONTENT_TYPE @"Content-Type"
//share Photo Constant
#define DOCUMENT_FILE_PATH @"Documents/originalImage.ig"
#define APP_URL @"instagram://app"
#define UTI_URL @"com.instagram.exclusivegram"
#define MESSAGE @"Instagram not installed in this device!\nTo share image please install instagram."
#endif /* ConstantHandler_h */
创建一个头文件,并提供头文件名为ConstantHandle
并设置所有身份验证URL
#ifndef ConstantHandler_h
#define ConstantHandler_h
//set User authentication and url
#define INSTAGRAM_AUTHURL @"https://api.instagram.com/oauth/authorize/"
#define INSTAGRAM_APIURl @"https://api.instagram.com/v1/users/"
#define INSTAGRAM_CLIENT_ID @"Client Id"
#define INSTAGRAM_CLIENTSERCRET @"Clients Secret"
#define INSTAGRAM_REDIRECT_URL @"Redirect URL"
#define INSTAGRAM_ACCESS_TOKEN @"access_token"
#define INSTAGRAM_SCOPE @"likes+comments+relationships+basic"
//Contant Url
#define ACCESS_TOKEN @"#access_token="
#define UNSIGNED @"UNSIGNED"
#define CODE @"code="
#define END_POINT_URL @"https://api.instagram.com/oauth/access_token"
#define HTTP_METHOD @"POST"
#define CONTENT_LENGTH @"Content-Length"
#define REQUEST_DATA @"application/x-www-form-urlencoded"
#define CONTENT_TYPE @"Content-Type"
//share Photo Constant
#define DOCUMENT_FILE_PATH @"Documents/originalImage.ig"
#define APP_URL @"instagram://app"
#define UTI_URL @"com.instagram.exclusivegram"
#define MESSAGE @"Instagram not installed in this device!\nTo share image please install instagram."
#endif /* ConstantHandler_h */
首先,设置所有微型
第2步。
Add a file in your project
Provide the file name is
InstagramController
将此代码添加到InstagramController.h文件中
#import <UIKit/UIKit.h>
#import "ConstantHandler.h"
@interface InstagramController : UIViewController
- (void)loginWithInstagramWithParsentViewController:(UIViewController *)controller completionHandler:(void(^)(NSDictionary *userProfileInformation))completionHanlder failureHandler:(void(^)(NSDictionary *errorDetail))failureHandler;
- (void)sharePhotoWithInstagaramWithImage:(UIImage *)image parsentViewcontroller:(UIViewController *)controller;;
@end
第4步。
Add a file in your project
Provide the file name is
构建并运行项目删除NSHTTPCookieStorage并使用应用程序传输安全。
并在webView请求之前添加webView委托。使用方法后,解除锁定并将webView委派设置为零。您的问题是什么?确切地说;你的“问题”看起来很像一个循序渐进的答案。@khurshid Hiii,我如何在swift 3中使用这个条件?