WPRM Example: Klout SEO API

In this example, we will validate a phone/mobile number using Klout API. Please, make sure that:

  • WP Restful Manager Plugin installed and active.
  • You read our quick launch example(Basic steps will not explained in this example).
  • Know what this API does.

In this API, we will go through 8 steps:

  1. Sign up in the API and get the API key.
  2. Establish a connection to get Klout Network Id.
  3. Create data request and Populate parameters values.
  4. Set data storing options.
  5. Establish a new connection for koultData.
  6. Create request and populate parameters values.
  7. Set display options.
  8. Customize the display template.
  1. Sign up in the API and get the API key:
    Go to documentation, sign up and get you API key.koult
  2. Establish a connection to get Klout Network Id:
      • Connection base url: http://api.klout.com/v2/identity.json/twitter
      • the results (response) format: json
      • The parameters Keys: key/ screenName

    These will be added as in the screenshot then save it:
    conk

  3. Create request and Populate parameters values:
    • key: it will be fixed value. then copy and paste the API key in the value source.
    • screenName: it could be a fixed value if you want to add fixed tweeter id. In this example, i assume that you store your users’ tweeter id as users meta so we will retrieve them dynamically.

    Save after you finish.
    reqk

  4. Set data storing options:
    • Display/store: We will only save the targeted output in the database output.
    •  Where to display results: If you use a fixed twitter id you can choose ‘save only’. But since it will be dynamic so we will use shortcode here.
    • Showing repeatable results: don’t check this option we don’t have repeatable data.
    • (save everything before this step)Start Checking dummy data: add all values in this section with full fixed(no dynamic work is here) dummy(but correct) data then click ‘check request’ once you see results check only the data that you want save which in this case will be the id. A dropdwon menu show up choose where to save. In this case will be user meta, select it then memorize the meta key that will show beside it.reqkd. once When you’re finished, click save.
  5. Establish a new connection for koultData.
    • Connection base url: http://api.klout.com/v2/user.json/{1}/{2} (this is called custom url. To provide flexibility, we made it easy to add parameters in the base url itself. The screenshot below will clear it out).
    • the results (response) format: json
    • The parameters Keys: networkid/type/key(the custom parameters’ keys can be given random names – names are only references here – but the key value parameters have to be given the same name as in the documentation).
    • activate the custom URLs checkbox.

    These will be added as in the screenshot then save it:
    conk2

  6. Create data request and populate parameters values:
    • networkid: choose ‘user meta’ and select the user meta key that you have just saved it in step #4.
    • type: if you had a look at the docs. You will find several types of data you can retrieve like Score, Influence, Topics, etc .. here we will choose score.
    • key: it will be fixed value. then copy and paste the API key in the value source(same as above).
      reqk2
  7. Set data storing options in the new request:
    • Display/store: here we will display data so select ‘Display Only’.
    •  Where to display results: we will use shortcode here.
    • Showing repeatable results: don’t check this option we don’t have repeatable data.
    • (save everything before this step)Start Checking dummy data: add all values in this section with full fixed(no dynamic work is here) dummy(but correct) data then click ‘check request’. You can get the ‘networkid’ from the previous request just by copy and paste it. Check whatever you want to display.

    reqkd2

  8. Create data request and populate parameters values:
    Now every thing is ready except how the results will look like!! so here comes the last section, ‘Template Settings’.

    • In Header or non-repeatable Template: this is the template that we’ll use. you can add text inline style and html to template you results. The links below the editor is a shorthand to help you copy and paste to the editor:
      • the results keys: score/bucket.
      • Functional helpers like: if/ifExists/sections

      In the screenshot below, we create a table then add the score of the twitter account at first row then the level of the score on the second row. We get the level by checking the bucket if it between 30-39, it will show Bad, and if it between 50-59, it shows Moderate, and so on. You can add as many [if] conditions as you like. reqktemp

    • Save the changes. After that get both requests shortcodes [rm req=xx] and add them in whatever page or post you like. Make sure you add them in the same order we created them so we can store the network id first. The screenshot below shows how it would look like. It’s so simple but it could be effective in real app or website.
      sampsk
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s