2017 © Pedro Peláez
 

library xing-php-sdk

A PHP wrapper for the XING api

image

bahuma/xing-php-sdk

A PHP wrapper for the XING api

  • Monday, January 11, 2016
  • by bahuma20
  • Repository
  • 2 Watchers
  • 1 Stars
  • 321 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 19 % Grown

The README.md

Xing PHP SDK

This is a PHP Wrapper for the Xing API based on guzzle 6. It simplifies the process of authenticating and requesting permission., (*1)

Installation

The best way to install Xing SDK is through composer:, (*2)

The best way to install php-sdk-for-XING is through composer:, (*3)

  1. Download the composer.phar executable or use the installer., (*4)

    sh $ curl -sS https://getcomposer.org/installer | php, (*5)

  2. add the following to your composer.json, (*6)

    ``` javascript { "require": { "bahuma/xing-php-sdk": "dev-master" } }, (*7)


    or just run ``` sh $ composer require bahuma/xing-php-sdk
  3. Run Composer: php composer.phar install, (*8)

And you should be done., (*9)

Example

You can find an advanced example in the file sample.php., (*10)

I recommend open this file and then read on., (*11)

Obtaining an Access Token

To get an access token you first have to register your application. Head over to https://dev.xing.com and register yourself for a Xing application to get the consumer key/secret which you have to use with this package., (*12)

Then you have to call the following functions in this order:, (*13)

  1. getRequestToken, (*14)

    Insert your consumer_key and your consumer_secret into the config array., (*15)

    Leave the token and token_secret blank., (*16)

    Then create a new XingSdk Object with this config., (*17)

    ``` php $config = [ 'consumer_key' => CONSUMER_KEY, 'consumer_secret' => CONSUMER_SECRET, 'token' => '', 'token_secret' => '', ];, (*18)

    $xingSdk = new XingSDK($config);, (*19)


    Then call the function with an url where the users are being redirected to after accepting the permissions. This URL is the callback-url. ``` php $result = $xing_api->getRequestToken("http://dev.bahuma.io/xing2?page=redirect");

    The function returns an array with three values., (*20)

    Save request_token and request_token_secret temporary. You'll need them in the next step., (*21)

    Redirect the user to the authorize_url. This is the page where the user clicks "accept"., (*22)

  2. getAccessToken, (*23)

    This function should be executed at the callback-url., (*24)

    Insert your consumer_key and your consumer_secret into the config array., (*25)

    Insert the request_token and request_token_secret from the previous field into the config array., (*26)

    Then create a new XingSdk Object with this config., (*27)

    ``` php $config = [ 'consumer_key' => CONSUMER_KEY, 'consumer_secret' => CONSUMER_SECRET, 'token' => $the_temporary_saved_request_token, 'token_secret' => $the_temporary_saved_request_token_secret, ];, (*28)

    $xingSdk = new XingSDK($config); ```, (*29)

    Then call the function using the value of the GET-Parameter oauth_verifier, which has been set by XING., (*30)

    php $result = $xing_api->getAccessToken($_GET['oauth_verifier']);, (*31)

    The function returns an array containing the access_token and the access_token_secret for the user, which has logged in. Save these values in your database or somewhere else where you can access them later., (*32)

Making calls to the XING-API

Now that you have obtained an access token, you can call the API. For example let's get the profile details of the user, which has logged in., (*33)

  1. Insert your consumer_key and your consumer_secret into the config array. Insert the access_token and access_token_secret from the user, which you have saved in your database,into the config array., (*34)

    php $config = array( 'consumer_key' => 'abc123456789xyz', 'consumer_secret' => 'abc123456789xyz', 'token' => $access_token_from_my_database, 'token_secret' => $access_token_secret_from_my_database, );, (*35)

  2. Create a new XingSDK Object. php $xingSdk = new XingSDK($config);, (*36)

  3. Get the Guzzle Client from the XingSDK Object. php $xingClient = $xingSDK->getClient();, (*37)

  4. Make the request. php // "users/me" is the endpoint of the Xing-API. See https://dev.xing.com/docs/resources $response = $xingClient->get('users/me');, (*38)

  5. Bonus: Get the request in a usable format. php $beautiful_response = XingSDK::decodeResponse($response); print_r($beautiful_response);, (*39)

And that's it., (*40)

For help how to use other request methods (GET/POST/PUT/DELETE/PATCH) or send content with your request, see the Guzzle Documentation., (*41)

The Versions

11/01 2016

dev-master

9999999-dev https://github.com/bahuma/xing-php-sdk

A PHP wrapper for the XING api

  Sources   Download

Apache 2.0

The Requires

 

by Max Bachhuber

composer library

11/01 2016

dev-analysis-q2knrz

dev-analysis-q2knrz https://github.com/bahuma/xing-php-sdk

A PHP wrapper for the XING api

  Sources   Download

Apache 2.0

The Requires

 

by Max Bachhuber

composer library

21/12 2015

v0.0.1

0.0.1.0 https://github.com/bahuma/xing-php-sdk

A PHP wrapper for the XING api

  Sources   Download

Apache 2.0

The Requires

 

by Max Bachhuber

composer library