如何在ios应用程序中集成Pinterest

时间:2022-09-15 15:52:01

I want to integrate pinterest in my application. i want to add button of pinterest in my app through which i can upload image on pinterest I refer their Developers site but it doesnt help me.

我想在我的应用程序中集成pinterest。我想在我的应用程序中添加pinterest按钮,通过它我可以在pinterest上传图像我推荐他们的开发者网站,但它并没有帮助我。

I include SDK and tried their code but it doesnt work for me.

我包含SDK并尝试了他们的代码,但它对我不起作用。

  #import <Pinterest/Pinterest.h>

UIButton* pinItButton = [Pinterest pinItButton];
    [pinItButton addTarget:self
                    action:@selector(pinIt:)
          forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:pinItButton];

 - (void)pinIt:(id)sender
    {
        [_pinterest createPinWithImageURL:@"http://placekitten.com/500/400"
                                sourceURL:@"http://placekitten.com"
                              description:@"Pinning from Pin It Demo"];
    }

please any help will be appreciated.

请任何帮助将不胜感激。

Thanks in advance.

提前致谢。

1 个解决方案

#1


30  

I dont understand whats your actual problem but here i provide some easy step to integrate pinterest to your app

我不明白你的实际问题是什么,但在这里我提供了一些简单的步骤来将pinterest集成到你的应用程序

step : 1 Register for a Client ID from here

步骤:1从此处注册客户端ID

step : 2 Download the SDK from here and drag and drop into your project.

步骤:2从此处下载SDK并拖放到您的项目中。

step : 3 You will then need to add a URL type to support opening your app from the Pinterest app , so add URL type to your plist file

步骤:3然后,您需要添加URL类型以支持从Pinterest应用程序打开您的应用程序,因此将URL类型添加到plist文件

Example if your client id is 18571937652947:
pin18571937652947 is the URL Scheme you need to support.

step : 4 To use the Pinterest framework you will need to import it into your file.

步骤:4要使用Pinterest框架,您需要将其导入到您的文件中。

 #import <Pinterest/Pinterest.h>

and declare its object in your .h file

并在.h文件中声明其对象

 Pinterest *pinterest

step : 5 initialise Pinterest object

步骤:5初始化Pinterest对象

 pinterest = [[Pinterest alloc]initWithClientId:@"your app client id"]

step : 6 To use the standard PinIt Button in a view add it as so:

步骤:6要在视图中使用标准PinIt按钮,请将其添加为:

 UIButton* pinItButton = [Pinterest pinItButton];
    [pinItButton addTarget:self
                    action:@selector(pinIt:)
          forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:pinItButton];

step : 7 You will need to handle the action an example of this is below:

步骤:7您将需要处理此操作的示例如下:

- (void)pinIt:(id)sender
{
    NSURL *imageURL     = [NSURL URLWithString:@"http://placekitten.com/500/400"];
    NSURL *sourceURL    = [NSURL URLWithString:@"http://placekitten.com"];


    [pinterest createPinWithImageURL:imageURL
                           sourceURL:sourceURL
                         description:@"Pinning from Pin It Demo"];
}

Note : pinterest app should be installed in your device otherwise this code redirect to itunes to download pinterest app

注意:pinterest应用程序应安装在您的设备中,否则此代码重定向到iTunes下载pinterest应用程序

#1


30  

I dont understand whats your actual problem but here i provide some easy step to integrate pinterest to your app

我不明白你的实际问题是什么,但在这里我提供了一些简单的步骤来将pinterest集成到你的应用程序

step : 1 Register for a Client ID from here

步骤:1从此处注册客户端ID

step : 2 Download the SDK from here and drag and drop into your project.

步骤:2从此处下载SDK并拖放到您的项目中。

step : 3 You will then need to add a URL type to support opening your app from the Pinterest app , so add URL type to your plist file

步骤:3然后,您需要添加URL类型以支持从Pinterest应用程序打开您的应用程序,因此将URL类型添加到plist文件

Example if your client id is 18571937652947:
pin18571937652947 is the URL Scheme you need to support.

step : 4 To use the Pinterest framework you will need to import it into your file.

步骤:4要使用Pinterest框架,您需要将其导入到您的文件中。

 #import <Pinterest/Pinterest.h>

and declare its object in your .h file

并在.h文件中声明其对象

 Pinterest *pinterest

step : 5 initialise Pinterest object

步骤:5初始化Pinterest对象

 pinterest = [[Pinterest alloc]initWithClientId:@"your app client id"]

step : 6 To use the standard PinIt Button in a view add it as so:

步骤:6要在视图中使用标准PinIt按钮,请将其添加为:

 UIButton* pinItButton = [Pinterest pinItButton];
    [pinItButton addTarget:self
                    action:@selector(pinIt:)
          forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:pinItButton];

step : 7 You will need to handle the action an example of this is below:

步骤:7您将需要处理此操作的示例如下:

- (void)pinIt:(id)sender
{
    NSURL *imageURL     = [NSURL URLWithString:@"http://placekitten.com/500/400"];
    NSURL *sourceURL    = [NSURL URLWithString:@"http://placekitten.com"];


    [pinterest createPinWithImageURL:imageURL
                           sourceURL:sourceURL
                         description:@"Pinning from Pin It Demo"];
}

Note : pinterest app should be installed in your device otherwise this code redirect to itunes to download pinterest app

注意:pinterest应用程序应安装在您的设备中,否则此代码重定向到iTunes下载pinterest应用程序