3

I tried to find a PHP SDK for Box API v 2.0, but didn't find it. I found only SDK for v1.0 https://github.com/box/box-php-sdk Does it exist?

OR

Is it possible to use refresh_token in Box API v1.0 in that v1.0 sdk https://github.com/box/box-php-sdk ?

Alex K
  • 31
  • 1
  • 2

2 Answers2

8

Wrote the PHP SDK for v2

Just include the api class and initiate the class:

<?php
    include('library/BoxAPI.class.php');

    $client_id = 'CLIENT ID';
    $client_secret = 'CLIENT SECRET';
    $redirect_uri = 'REDIRECT URL';
    $box = new Box_API($client_id, $client_secret, $redirect_uri);

    if(!$box->load_token()){
        if(isset($_GET['code'])){
            $token = $box->get_token($_GET['code'], true);
            if($box->write_token($token, 'file')){
                $box->load_token();
            }
        } else {
            $box->get_code();
        }
    }
    // User details
    $box->get_user();
?>

Have a look here Download: BoxPHPAPI

Rahil Wazir
  • 10,007
  • 11
  • 42
  • 64
golchha21
  • 314
  • 3
  • 10
0

We don't currently have an PHP SDK for v2 though we are working on one.

OAuth 2 tokens (refresh and access) will only work with the V2 API.

seanrose
  • 8,185
  • 3
  • 20
  • 21
  • We implemented Box API in our app, but right now its logging users out every hour. Any ideas how it can be changed? – Alex K Feb 04 '13 at 18:39
  • The access_token will expire, but you can use the supplied refresh_token to retrieve another one. Here is more information on our OAuth2 implementation: http://developers.box.com/oauth/ – seanrose Feb 05 '13 at 01:38