Developer Platform (July 2017)

Getting started with the first sample

«  Code samples, examples, and walk-throughs   ·  [   home  ·   reference  ·   community   ·  search   ·  index   ·  routing table   ·  scopes table   ]   ·  Change some profile data  »

The first samples, available in a number of language bindings, serves as the first example for using the Learning Framework APIs. These sample use the client libraries to assist with the authentication steps that all client applications must go through, and provides a very simple web-service framework to help you see how several simple API calls can work.

Basic Sample. This slightly less complex sample uses only the whoami API call to demonstrate the basics:

Walk-through. The basic sample provides a simple framework surrounding a single API call in the form of a simple-web form. Once you deploy the sample appropriate for the platform you want, and run it, you should see the sample’s starting web-page in your browser.

When you click the Login button, the page redirects your browser to the D2L login page hosted on http://lms.valence.desire2learn.com/.

After you authenticate, the flow redirects back to the sample page which should now be filled out with some of your whoami information.

Getting Started. This slighly more complex sample uses the get versions and whoami API calls to show you the basics:

Walk-through. This sample provides a simple framework surrounding several API calls in the form of a simple web-form. Once you deploy the sample appropriate for the platform you want, and run it, you should see the sample’s web-form in your browser:

  1. Click the Authenticate button.
    • The form redirects your browser to the D2L login page hosted on http://lms.valence.desire2learn.com/.
    • Fill out your test user name and password for the service (authenticating yourself as a user), and click Login.
    • The service redirects you back to your sample web-form.
    • If you click Authenticate again, you will see your user credentials.
  2. Click on the Get Versions button.
    • The form makes a call to the service’s get versions route to retrieve the service’s API version properties.
  3. Click on the Who Am I? button.
    • The form makes a call to the service’s whoami route to retrieve the whoami properties for the current user context.

Online

We host an online version of the Getting Started sample you can use. By default, it assumes that lms.valence.desire2learn.com is the back-end host, but you can use it to point at you service (as long as it’s visible to the internet).

To run the sample. Point a browser at http://samples.valence.desire2learn.com/samples/GettingStartedSample/.

C#/.NET

The Basic sample for the C#/.NET has the same requirements as the C# client library.

With Visual Studio, open the Basic.sln solution from within the .../samples/Basic sample directory, and build the project to try it out.

Java

The GettingStarted sample for the Java SE runtime has the same requirements as the Java SE client library. You will also require access to a local Tomcat instance as a web-service hosting environment.

To install. First, copy the samples/GettingStartedSample/build/web directory to your Tomcat server’s webapps folder, renaming the folder to the web-application name you want to use. Restart the Tomcat service if you don’t have it set to autoDeploy.

To run the sample. Point a browser at http(s)://<yourservername>/<webappname>/.

JavaScript

The GettingStarted sample for the JavaScript platform has the same requirements as the JavaScript client library.

To install. Copy the entire valence-sdk-javascript SDK folder to a local directory where you can access its contents via HTTP (in most Unix systems, you can add the contents to /var/www, or create a virtual host; in Windows, you can create a public profile in IIS).

To run the sample. Point a browser to the sample by navigating to http://yourServer/docRoot/valence-sdk-javascript/sample/GettingStartedSample/index.html.

Note

The Valence JavaScript SDK also comes with a Node.js version of the getting started sample: we recommend that you also deploy and try this out, as if you intend to use Javascript for Valence projects, you should not be deploying your Application credentials to the client side.

PHP

The Basic sample for the PHP platform has the same requirements as the PHP client library.

To install. Copy the entire valence-sdk-php SDK folder to a local directory inside your webserver’s document tree (in most Unix systems, you can add the contents to /var/www, or create a virtual host; in Windows, you can create a public profile in IIS).

Copy the BasicSample folder from your SDK samples directory into a directory that’s in your web servier’s path.

To run the sample. Point a browser to the sample by navigating to http://yourServer/docRoot/valence-sdk-php/sample/BasicSample/index.php.

Python

The Basic sample for the Python platform has the same requirements as the Python client library. You will also require the Bottle and Beaker Python packages, as the sample is implemented as a simple web services application in a Bottle framework using Beaker to manage session state data.

To install. First, download the latest version of the Python sample repository. Then, unzip the contents into a temporary folder.

To run the sample. From within the Basic sample subdirectory, run the basic.py script to start the Bottle web-service application. Then, in a web-browser, navigate to http://localhost:8080/start.

«  Code samples, examples, and walk-throughs   ·  [   home  ·   reference  ·   community   ·  search   ·  index   ·  routing table   ·  scopes table   ]   ·  Change some profile data  »