Giter Site home page Giter Site logo

fossabot / xing-api-haskell Goto Github PK

View Code? Open in Web Editor NEW

This project forked from janahrens/xing-api-haskell

0.0 1.0 0.0 93 KB

Haskell wrapper for the XING API

Home Page: http://hackage.haskell.org/package/xing-api

License: BSD 3-Clause "New" or "Revised" License

Makefile 1.84% Haskell 98.16%

xing-api-haskell's Introduction

xing-api

Build Status FOSSA Status

This Haskell library is a wrapper for the XING API.

It's currently under development and is not considered stable. This library is a private project and isn't associated with XING AG.

Usage

To use this minimal working example you'll need to get a consumer key and secret from the XING developer site.

{-# LANGUAGE OverloadedStrings #-}

import Web.XING
import qualified Data.ByteString.Char8 as BS

oauthConfig :: OAuth
oauthConfig = consumer "YOUR_CONSUMER_KEY" "YOUR_CONSUMER_SECRET"

main :: IO ()
main = withManager $ \manager -> do
  (accessToken, _) <- handshake manager
  idCard <- getIdCard oauthConfig manager accessToken
  liftIO $ putStrLn $ show idCard
  where
    handshake manager = do
      (requestToken, url) <- getRequestToken oauthConfig manager
      verifier <- liftIO $ do
        BS.putStrLn url
        BS.putStr "PIN: "
        BS.getLine
      getAccessToken requestToken verifier oauthConfig manager

GHCI session

If you want to test this library using GHCI, you can use this snippet as a starting point.

$ ghci -XOverloadedStrings
:module +Network.HTTP.Conduit
manager <- newManager def

:module +Web.XING
let oauth = consumer "CONSUMER_KEY" "CONSUMER_SECRET"

:module +Control.Monad.Trans.Resource
(requestToken, url) <- runResourceT (getRequestToken oauth manager)
url

(accessToken, userId) <- runResourceT (getAccessToken requestToken "THE_PIN_YOU_GOT_FROM_XING" oauth manager)
userId

Development environment

The simplest way to setup a development environment is to use Docker.

docker build -t xing-api-haskell .

You can then bind your local git repository as a volume in Docker:

docker run -i -t --rm -v /etc/ssl/certs:/etc/ssl/certs -v $PWD:/opt/app xing-api-haskell ghci

I might be useful to reuse the CA store from your local maschine, because the container does not contain any CAs.

To test a simple interaction with the API, you can copy and paste the following snippet into the ghci session:

withManager $ \manager -> getRequestToken (consumer "YOUR_CONSUMER_KEY" "YOUR_CONSUMER_SECRET") manager

This repository includes several demo programs. To use them, you have to obtain an API consumer key by registering your application at the XING developer portal. Put the consumer key and secret in the demos/Config.hs file (the test consumer key is enough). The Config.hs.template file is recommended to be used as a template.

cp Config.hs.template Config.hs

License

FOSSA Status

xing-api-haskell's People

Contributors

fossabot avatar janahrens avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.