Skip to content

Commit 2cc1c53

Browse files
committed
Merge pull request #10 from behance/feature-token
Client: Use access_token key const
2 parents 96a5fe0 + d37d551 commit 2cc1c53

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

lib/Be/Api.php

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class Be_Api {
2929
const VALID = 1;
3030
const INVALID = 0;
3131

32+
const ACCESS_TOKEN_KEY = 'access_token';
33+
3234
protected $_api_root = 'https://www.behance.net/v2';
3335

3436
protected $_client_id,
@@ -376,9 +378,9 @@ public function getUserWips( $id_or_username, $params = array(), $assoc = false
376378
*/
377379
public function createUserWip( $image_path, $title, array $tags, $description = '', $assoc = false ) {
378380

379-
$endpoint = self::ENDPOINT_WIPS;
381+
$endpoint = self::ENDPOINT_WIPS;
380382

381-
$query_params['access_token'] = $this->_access_token;
383+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
382384

383385
$post_body['tags'] = implode( '|', $tags );
384386
$post_body['image'] = '@' . $image_path;
@@ -412,7 +414,7 @@ public function createUserWipRevision( $wip_id, $image_path, $title, array $tags
412414

413415
$endpoint = self::ENDPOINT_WIPS . '/' . $id;
414416

415-
$query_params['access_token'] = $this->_access_token;
417+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
416418

417419
$post_body['tags'] = implode( '|', $tags );
418420
$post_body['image'] = '@' . $image_path;
@@ -444,7 +446,7 @@ public function updateUserWipRevisionDescription( $wip_id, $revision_id, $descri
444446

445447
$endpoint = self::ENDPOINT_WIPS . '/' . $wip_id . '/' . $revision_id;
446448

447-
$query_params['access_token'] = $this->_access_token;
449+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
448450

449451
$put_body['description'] = $description;
450452

@@ -469,7 +471,7 @@ public function updateUserWipTitle( $wip_id, $title, $assoc = false ) {
469471

470472
$endpoint = self::ENDPOINT_WIPS . '/' . $wip_id ;
471473

472-
$query_params['access_token'] = $this->_access_token;
474+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
473475

474476
$put_body['title'] = $title;
475477

@@ -495,7 +497,7 @@ public function updateUserWipRevisionTags( $wip_id, $revision_id, array $tags, $
495497

496498
$endpoint = self::ENDPOINT_WIPS . '/' . $wip_id . '/' . $revision_id;
497499

498-
$query_params['access_token'] = $this->_access_token;
500+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
499501

500502
$put_body['tags'] = implode( '|', $tags );
501503

@@ -521,7 +523,7 @@ public function postWipComment( $wip_id, $revision_id, $comment, $assoc = false
521523

522524
$endpoint = self::ENDPOINT_WIPS . '/' . $id . '/' . $revision_id . '/comments';
523525

524-
$query_params['access_token'] = $this->_access_token;
526+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
525527
$body_params['comment'] = $comment;
526528

527529
$response = $this->_post( $endpoint, $query_params, $body_params );
@@ -545,7 +547,7 @@ public function deleteUserWipRevision( $wip_id, $revision_id, $assoc = false ) {
545547

546548
$endpoint = self::ENDPOINT_WIPS . '/' . $wip_id . '/' . $revision_id;
547549

548-
$query_params['access_token'] = $this->_access_token;
550+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
549551

550552
$response = $this->_delete( $endpoint, $query_params );
551553

@@ -567,7 +569,7 @@ public function deleteUserWip( $wip_id, $assoc = false ) {
567569

568570
$endpoint = self::ENDPOINT_WIPS . '/' . $wip_id ;
569571

570-
$query_params['access_token'] = $this->_access_token;
572+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
571573

572574
$response = $this->_delete( $endpoint, $query_params );
573575

@@ -656,7 +658,7 @@ public function createCollection( $title, $project_ids = array(), $assoc = false
656658

657659
$endpoint = self::ENDPOINT_COLLECTIONS;
658660

659-
$query_params['access_token'] = $this->_access_token;
661+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
660662
$body_params['title'] = $title;
661663

662664
if ( !empty( $project_ids ) )
@@ -683,7 +685,7 @@ public function deleteCollection( $id, $assoc = false ) {
683685

684686
$endpoint = self::ENDPOINT_COLLECTIONS . '/' . $id;
685687

686-
$query_params['access_token'] = $this->_access_token;
688+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
687689

688690
$response = $this->_delete( $endpoint, $query_params );
689691

@@ -706,7 +708,7 @@ public function updateCollection( $id, $title, $assoc = false ) {
706708

707709
$endpoint = self::ENDPOINT_COLLECTIONS . '/' . $id;
708710

709-
$query_params['access_token'] = $this->_access_token;
711+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
710712
$body_params['title'] = $title;
711713

712714
$response = $this->_put( $endpoint, $query_params, $body_params );
@@ -753,7 +755,7 @@ public function addProjectsToCollection( $id, array $project_ids, $assoc = false
753755

754756
$projects = implode( '|', $project_ids );
755757

756-
$query_params['access_token'] = $this->_access_token;
758+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
757759

758760
$body_params['projects'] = $projects;
759761

@@ -779,7 +781,7 @@ public function removeProjectFromCollection( $id, $project_id, $assoc = false )
779781

780782
$endpoint = self::ENDPOINT_COLLECTIONS . '/' . $id . '/projects/' . $project_id;
781783

782-
$query_params['access_token'] = $this->_access_token;
784+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
783785

784786
$response = $this->_delete( $endpoint, $query_params );
785787

@@ -845,7 +847,7 @@ public function viewProject( $id, $assoc = false ) {
845847

846848
$endpoint = self::ENDPOINT_PROJECTS . '/' . $id . '/view';
847849

848-
$query_params['access_token'] = $this->_access_token;
850+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
849851

850852
$response = $this->_post( $endpoint, $query_params );
851853

@@ -867,7 +869,7 @@ public function appreciateProject( $id, $assoc = false ) {
867869

868870
$endpoint = self::ENDPOINT_PROJECTS . '/' . $id . '/appreciate';
869871

870-
$query_params['access_token'] = $this->_access_token;
872+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
871873

872874
$response = $this->_post( $endpoint, $query_params );
873875

@@ -890,7 +892,7 @@ public function postProjectComment( $id, $comment, $assoc = false ) {
890892

891893
$endpoint = self::ENDPOINT_PROJECTS . '/' . $id . '/comments';
892894

893-
$query_params['access_token'] = $this->_access_token;
895+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
894896
$body_params['comment'] = $comment;
895897

896898
$response = $this->_post( $endpoint, $query_params, $body_params );
@@ -913,7 +915,7 @@ public function followCollection( $id, $assoc = false ) {
913915

914916
$endpoint = self::ENDPOINT_COLLECTIONS . '/' . $id . '/follow';
915917

916-
$query_params['access_token'] = $this->_access_token;
918+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
917919

918920
$response = $this->_post( $endpoint, $query_params );
919921

@@ -935,7 +937,7 @@ public function unfollowCollection( $id, $assoc = false ) {
935937

936938
$endpoint = self::ENDPOINT_COLLECTIONS . '/' . $id . '/follow';
937939

938-
$query_params['access_token'] = $this->_access_token;
940+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
939941

940942
$response = $this->_delete( $endpoint, $query_params );
941943

@@ -1041,7 +1043,7 @@ public function followUser( $id_or_username, $assoc = false ) {
10411043

10421044
$endpoint = self::ENDPOINT_USERS . "/{$id_or_username}/follow";
10431045

1044-
$query_params['access_token'] = $this->_access_token;
1046+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
10451047

10461048
$response = $this->_post( $endpoint, $query_params );
10471049

@@ -1063,7 +1065,7 @@ public function unfollowUser( $id_or_username, $assoc = false ) {
10631065

10641066
$endpoint = self::ENDPOINT_USERS . "/{$id_or_username}/follow";
10651067

1066-
$query_params['access_token'] = $this->_access_token;
1068+
$query_params[ self::ACCESS_TOKEN_KEY ] = $this->_access_token;
10671069

10681070
$response = $this->_delete( $endpoint, $query_params );
10691071

0 commit comments

Comments
 (0)