1616 */
1717class Be_Api {
1818
19- const ENDPOINT_PROJECTS = '/projects ' ;
20- const ENDPOINT_USERS = '/users ' ;
21- const ENDPOINT_WIPS = '/wips ' ;
22- const ENDPOINT_COLLECTIONS = '/collections ' ;
23- const ENDPOINT_ACTIVITY = '/activity ' ;
24- const ENDPOINT_AUTHENTICATE = '/oauth/authenticate ' ;
25- const ENDPOINT_TOKEN = '/oauth/token ' ;
26- const ENDPOINT_FIELDS = '/fields ' ;
27-
28- const TIMEOUT_DEFAULT_SEC = 30 ;
29- const VALID = 1 ;
30- const INVALID = 0 ;
31-
32- const ACCESS_TOKEN_KEY = 'access_token ' ;
33-
34- protected $ _api_root = 'https://www.behance.net/v2 ' ;
19+ const ENDPOINT_PROJECTS = '/projects ' ;
20+ const ENDPOINT_USERS = '/users ' ;
21+ const ENDPOINT_WIPS = '/wips ' ;
22+ const ENDPOINT_COLLECTIONS = '/collections ' ;
23+ const ENDPOINT_ACTIVITY = '/activity ' ;
24+ const ENDPOINT_AUTHENTICATE = '/oauth/authenticate ' ;
25+ const ENDPOINT_TOKEN = '/oauth/token ' ;
26+ const ENDPOINT_FIELDS = '/fields ' ;
27+
28+ const TIMEOUT_DEFAULT_SEC = 30 ;
29+ const VALID = 1 ;
30+ const INVALID = 0 ;
31+
32+ protected $ _api_root = 'https://www.behance.net/v2 ' ;
33+ protected $ _access_token_key = 'access_token ' ;
3534
3635 protected $ _client_id ,
3736 $ _client_secret ,
@@ -309,7 +308,7 @@ public function getUserFollowers( $id_or_username, $options = array(), $assoc =
309308 $ endpoint = self ::ENDPOINT_USERS . '/ ' . $ id_or_username . '/followers ' ;
310309
311310 if ( !empty ( $ this ->_access_token ) )
312- $ options [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
311+ $ options [ $ this -> _access_token_key ] = $ this ->_access_token ;
313312
314313 $ results = $ this ->_getDecodedJson ( $ endpoint , $ options , 'followers ' , $ assoc );
315314
@@ -380,7 +379,7 @@ public function createUserWip( $image_path, $title, array $tags, $description =
380379
381380 $ endpoint = self ::ENDPOINT_WIPS ;
382381
383- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
382+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
384383
385384 $ post_body ['tags ' ] = implode ( '| ' , $ tags );
386385 $ post_body ['image ' ] = '@ ' . $ image_path ;
@@ -414,7 +413,7 @@ public function createUserWipRevision( $wip_id, $image_path, $title, array $tags
414413
415414 $ endpoint = self ::ENDPOINT_WIPS . '/ ' . $ id ;
416415
417- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
416+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
418417
419418 $ post_body ['tags ' ] = implode ( '| ' , $ tags );
420419 $ post_body ['image ' ] = '@ ' . $ image_path ;
@@ -446,7 +445,7 @@ public function updateUserWipRevisionDescription( $wip_id, $revision_id, $descri
446445
447446 $ endpoint = self ::ENDPOINT_WIPS . '/ ' . $ wip_id . '/ ' . $ revision_id ;
448447
449- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
448+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
450449
451450 $ put_body ['description ' ] = $ description ;
452451
@@ -471,7 +470,7 @@ public function updateUserWipTitle( $wip_id, $title, $assoc = false ) {
471470
472471 $ endpoint = self ::ENDPOINT_WIPS . '/ ' . $ wip_id ;
473472
474- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
473+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
475474
476475 $ put_body ['title ' ] = $ title ;
477476
@@ -497,7 +496,7 @@ public function updateUserWipRevisionTags( $wip_id, $revision_id, array $tags, $
497496
498497 $ endpoint = self ::ENDPOINT_WIPS . '/ ' . $ wip_id . '/ ' . $ revision_id ;
499498
500- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
499+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
501500
502501 $ put_body ['tags ' ] = implode ( '| ' , $ tags );
503502
@@ -523,7 +522,7 @@ public function postWipComment( $wip_id, $revision_id, $comment, $assoc = false
523522
524523 $ endpoint = self ::ENDPOINT_WIPS . '/ ' . $ id . '/ ' . $ revision_id . '/comments ' ;
525524
526- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
525+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
527526 $ body_params ['comment ' ] = $ comment ;
528527
529528 $ response = $ this ->_post ( $ endpoint , $ query_params , $ body_params );
@@ -547,7 +546,7 @@ public function deleteUserWipRevision( $wip_id, $revision_id, $assoc = false ) {
547546
548547 $ endpoint = self ::ENDPOINT_WIPS . '/ ' . $ wip_id . '/ ' . $ revision_id ;
549548
550- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
549+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
551550
552551 $ response = $ this ->_delete ( $ endpoint , $ query_params );
553552
@@ -569,7 +568,7 @@ public function deleteUserWip( $wip_id, $assoc = false ) {
569568
570569 $ endpoint = self ::ENDPOINT_WIPS . '/ ' . $ wip_id ;
571570
572- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
571+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
573572
574573 $ response = $ this ->_delete ( $ endpoint , $ query_params );
575574
@@ -592,7 +591,7 @@ public function getUserActivity( $offset_ts = false, $assoc = false ) {
592591 $ endpoint = self ::ENDPOINT_ACTIVITY ;
593592
594593 $ params ['offset_ts ' ] = $ offset_ts ;
595- $ params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
594+ $ params [ $ this -> _access_token_key ] = $ this ->_access_token ;
596595
597596 $ results = $ this ->_getDecodedJson ( $ endpoint , $ params , 'activity ' , $ assoc );
598597
@@ -658,7 +657,7 @@ public function createCollection( $title, $project_ids = array(), $assoc = false
658657
659658 $ endpoint = self ::ENDPOINT_COLLECTIONS ;
660659
661- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
660+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
662661 $ body_params ['title ' ] = $ title ;
663662
664663 if ( !empty ( $ project_ids ) )
@@ -685,7 +684,7 @@ public function deleteCollection( $id, $assoc = false ) {
685684
686685 $ endpoint = self ::ENDPOINT_COLLECTIONS . '/ ' . $ id ;
687686
688- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
687+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
689688
690689 $ response = $ this ->_delete ( $ endpoint , $ query_params );
691690
@@ -708,7 +707,7 @@ public function updateCollection( $id, $title, $assoc = false ) {
708707
709708 $ endpoint = self ::ENDPOINT_COLLECTIONS . '/ ' . $ id ;
710709
711- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
710+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
712711 $ body_params ['title ' ] = $ title ;
713712
714713 $ response = $ this ->_put ( $ endpoint , $ query_params , $ body_params );
@@ -755,7 +754,7 @@ public function addProjectsToCollection( $id, array $project_ids, $assoc = false
755754
756755 $ projects = implode ( '| ' , $ project_ids );
757756
758- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
757+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
759758
760759 $ body_params ['projects ' ] = $ projects ;
761760
@@ -781,7 +780,7 @@ public function removeProjectFromCollection( $id, $project_id, $assoc = false )
781780
782781 $ endpoint = self ::ENDPOINT_COLLECTIONS . '/ ' . $ id . '/projects/ ' . $ project_id ;
783782
784- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
783+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
785784
786785 $ response = $ this ->_delete ( $ endpoint , $ query_params );
787786
@@ -847,7 +846,7 @@ public function viewProject( $id, $assoc = false ) {
847846
848847 $ endpoint = self ::ENDPOINT_PROJECTS . '/ ' . $ id . '/view ' ;
849848
850- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
849+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
851850
852851 $ response = $ this ->_post ( $ endpoint , $ query_params );
853852
@@ -869,7 +868,7 @@ public function appreciateProject( $id, $assoc = false ) {
869868
870869 $ endpoint = self ::ENDPOINT_PROJECTS . '/ ' . $ id . '/appreciate ' ;
871870
872- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
871+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
873872
874873 $ response = $ this ->_post ( $ endpoint , $ query_params );
875874
@@ -892,7 +891,7 @@ public function postProjectComment( $id, $comment, $assoc = false ) {
892891
893892 $ endpoint = self ::ENDPOINT_PROJECTS . '/ ' . $ id . '/comments ' ;
894893
895- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
894+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
896895 $ body_params ['comment ' ] = $ comment ;
897896
898897 $ response = $ this ->_post ( $ endpoint , $ query_params , $ body_params );
@@ -915,7 +914,7 @@ public function followCollection( $id, $assoc = false ) {
915914
916915 $ endpoint = self ::ENDPOINT_COLLECTIONS . '/ ' . $ id . '/follow ' ;
917916
918- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
917+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
919918
920919 $ response = $ this ->_post ( $ endpoint , $ query_params );
921920
@@ -937,7 +936,7 @@ public function unfollowCollection( $id, $assoc = false ) {
937936
938937 $ endpoint = self ::ENDPOINT_COLLECTIONS . '/ ' . $ id . '/follow ' ;
939938
940- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
939+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
941940
942941 $ response = $ this ->_delete ( $ endpoint , $ query_params );
943942
@@ -1043,7 +1042,7 @@ public function followUser( $id_or_username, $assoc = false ) {
10431042
10441043 $ endpoint = self ::ENDPOINT_USERS . "/ {$ id_or_username }/follow " ;
10451044
1046- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
1045+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
10471046
10481047 $ response = $ this ->_post ( $ endpoint , $ query_params );
10491048
@@ -1065,7 +1064,7 @@ public function unfollowUser( $id_or_username, $assoc = false ) {
10651064
10661065 $ endpoint = self ::ENDPOINT_USERS . "/ {$ id_or_username }/follow " ;
10671066
1068- $ query_params [ static :: ACCESS_TOKEN_KEY ] = $ this ->_access_token ;
1067+ $ query_params [ $ this -> _access_token_key ] = $ this ->_access_token ;
10691068
10701069 $ response = $ this ->_delete ( $ endpoint , $ query_params );
10711070
@@ -1107,6 +1106,16 @@ public function setApiRoot( $url ) {
11071106
11081107 } // setApiRoot
11091108
1109+ /**
1110+ * Set access token key
1111+ *
1112+ * @param string $key
1113+ */
1114+ public function setAccessTokenKey ( $ key ) {
1115+
1116+ $ this ->_access_token_key = $ key ;
1117+
1118+ } // setAccessTokenKey
11101119
11111120 /**
11121121 * Automates retrieval data from $endpoint, using $query_params, and returns stdClass based on presence of $root_node
0 commit comments