B4A Library PinIt (Pinterest)

Here we have a wrapper for the PinIt SDK found

Here

From that page you will need to download the SDK and sign up for a ClientID. I found you need to be logged in to the site to apply for the ClientID. Just clicking the 'Register for Client ID' link without being logged in gives an error.

This SDK allows you to build a Pin adding details for Image, a description and Pin URL. The SDK then sends the Pin to the Pinterest app on your device. If you do not have the app installed, it takes you to the play store in order to install it.

Installation:
Download the library file below, extract them from the archive and copy them to your additional Libraries folder.

Next, unpack the SDK files I told you to download earlier and locate the .jar file named 'pinit-sdk-x.x.jar' the x's being the version number (currently 1.0). rename the file to just 'pinit-sdk.jar. and copy this too to your additional libraries folder.

Usage:
Usage is fairly simple, declare your instance with something like
B4X:
Dim Pin As PinIt

Initialize the object
B4X:
Pin.Initialize("Pin", "1234567") 'Replace 1234567 with your ClientID

Then setup the Pin with
B4X:
pin.Url="http://www.yourlink.com"
pin.Description = "Some Pin sent from my B4A app"
pin.ImageUrl="http://www.somelinktoanimage.com/image.jpg"

Finally, to send the Pin to the pinterest app, call
B4X:
Pin.doPinIt()

Once sent to the pinterest app, you choose your board to pin to and Pin. Simple!

There is also a second object/class in the library which is a pre-defined button called PinItButton. The usage is similar although you do not have to manage the click event of the button. This is done inside the SDK. Personally I think the PinIt is better than PinItButton. Easier to follow and the doPinIt method doesn't have to be related to a button.

There are 3 events to use these would be
B4X:
Sub Pin_Start()
    Log("pin started")
End Sub

Sub Pin_Complete(Completed As Boolean)
    If Completed Then Log("Completed = " & Completed)
End Sub

Sub Pin_Error(Error As String)
    Log("throwing wobbler - " & Error)
End Sub

The source code is now available on Learnb4a.com

Documentation:
  • PinIt
    Events:
    • Complete (Completed as Boolean As )
    • Error (Error as String As )
    • Start ( As )
    Methods:
    • Initialize (EventName As String, ClientID As String)
      Initializes the PinIt object.
      EventName - The sub that will handle the events
      ClientID - To use PinIt you must obtain a ClientID (sometimes known as PartnerID). Enter it here.
    • Initilize2 (EventName As String, ClientID As String)
      Same as Initialize but sets Debug mode to True.
    • IsInitialized As Boolean
    • Reset
      Reset the PinIt object to a blank state
    • doPinIt
      This invokes the native Pinterest Android app to perform a pin action.
      If Pinterest is not installed or the installed version does not support this feature the user will be sent to Google Play to install or update before continuing.
    • isDebugMode As Boolean
      Returns the state of Debug Mode
    Properties:
    • Description As String
      Sets or Gets the Description related to the Pin
    • ImageUri As Uri
      Sets or Gets the ImageUri related to the Pin
    • ImageUrl As String
      Sets or Gets the ImageUrl related to the Pin
    • MeetsRequirements As Boolean [read only]
    • Url As String
      Sets or Get the Url the Pin will link to
  • PinItButton
    Events:
    • Complete (Completed as Boolean As )
    • Error (Error as String As )
    • Start ( As )
    Methods:
    • Initialize (EventName As String)
      Initializes the object
      EventName - The sub that will handle the events
    • IsInitialized As Boolean
    • PinIt
      Call to send the Pin
    • Reset
      Resets the PinIt Button to a blank state.
    Properties:
    • Description As String [write only]
      Sets the Description for the Pin.
    • ImageUri As Uri [write only]
      Sets the image Uri the Pin
    • ImageUrl As String [write only]
      Sets the image Url for the Pin.
    • Url As String [write only]
      Sets the Url for the Pin.
      Only required if ImageUrl is set.

Thanks for looking.
 

Attachments

  • PinIt.zip
    6.4 KB · Views: 191
Last edited:

barx

Well-Known Member
Licensed User
Longtime User
Just to note. pinterest appear to have changed their app but not updated the sky so this no longer works, so I'm told...
 

barx

Well-Known Member
Licensed User
Longtime User
I haven't tested it, in fact I never proved that it didn't work, I created this library for another user who was using it happily and after a Pinterest update, he reported it no longer worked. The SDK download is still v1.0 so either it didn't break or they still haven't updated. Download it and try if you wish, I will when I get a few minutes...
 
Top