Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
r2373@opsdev009 (orig r113847): srush | 2008-08-02 16:11:10 -0700
Browse files Browse the repository at this point in the history
 add canvas user information to client library
  • Loading branch information
(no author) committed Aug 2, 2008
1 parent a379f0d commit 797b37a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
10 changes: 10 additions & 0 deletions clients/php/branches/redesign-changes/facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Facebook {
public $fb_params;
public $user;
public $profile_user;
public $canvas_user;
public function __construct($api_key, $secret, $generate_session_secret=false) {
$this->api_key = $api_key;
$this->secret = $secret;
Expand All @@ -58,6 +59,9 @@ public function __construct($api_key, $secret, $generate_session_secret=false) {
if (isset($this->fb_params['added'])) {
$this->api_client->added = $this->fb_params['added'];
}
if (isset($this->fb_params['canvas_user'])) {
$this->api_client->canvas_user = $this->fb_params['canvas_user'];
}
}

public function validate_fb_params($resolve_auth_token=true) {
Expand All @@ -75,6 +79,8 @@ public function validate_fb_params($resolve_auth_token=true) {
// the wrong user.
$user = isset($this->fb_params['user']) ? $this->fb_params['user'] : null;
$this->profile_user = isset($this->fb_params['profile_user']) ? $this->fb_params['profile_user'] : null;
$this->canvas_user = isset($this->fb_params['canvas_user']) ? $this->fb_params['canvas_user'] : null;

if (isset($this->fb_params['session_key'])) {
$session_key = $this->fb_params['session_key'];
} else if (isset($this->fb_params['profile_session_key'])) {
Expand Down Expand Up @@ -174,6 +180,10 @@ public function get_loggedin_user() {
return $this->user;
}

public function get_canvas_user() {
return $this->canvas_user;
}

public function get_profile_user() {
return $this->profile_user;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class FacebookRestClient {
public $api_key;
public $friends_list; // to save making the friends.get api call, this will get prepopulated on canvas pages
public $added; // to save making the users.isAppAdded api call, this will get prepopulated on canvas pages
public $canvas_user; // to direct the friends_get call for non-logged in users
public $batch_mode;
private $batch_queue;
private $call_as_apikey;
Expand Down Expand Up @@ -398,7 +399,11 @@ public function &friends_get() {
if (isset($this->friends_list)) {
return $this->friends_list;
}
return $this->call_method('facebook.friends.get', array());
$params = array();
if (isset($this->canvas_user)) {
$params['uid'] = $this->canvas_user;
}
return $this->call_method('facebook.friends.get', $params);
}

/**
Expand Down
10 changes: 10 additions & 0 deletions samples/smiley/client/facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Facebook {
public $fb_params;
public $user;
public $profile_user;
public $canvas_user;
public function __construct($api_key, $secret, $generate_session_secret=false) {
$this->api_key = $api_key;
$this->secret = $secret;
Expand All @@ -58,6 +59,9 @@ public function __construct($api_key, $secret, $generate_session_secret=false) {
if (isset($this->fb_params['added'])) {
$this->api_client->added = $this->fb_params['added'];
}
if (isset($this->fb_params['canvas_user'])) {
$this->api_client->canvas_user = $this->fb_params['canvas_user'];
}
}

public function validate_fb_params($resolve_auth_token=true) {
Expand All @@ -75,6 +79,8 @@ public function validate_fb_params($resolve_auth_token=true) {
// the wrong user.
$user = isset($this->fb_params['user']) ? $this->fb_params['user'] : null;
$this->profile_user = isset($this->fb_params['profile_user']) ? $this->fb_params['profile_user'] : null;
$this->canvas_user = isset($this->fb_params['canvas_user']) ? $this->fb_params['canvas_user'] : null;

if (isset($this->fb_params['session_key'])) {
$session_key = $this->fb_params['session_key'];
} else if (isset($this->fb_params['profile_session_key'])) {
Expand Down Expand Up @@ -174,6 +180,10 @@ public function get_loggedin_user() {
return $this->user;
}

public function get_canvas_user() {
return $this->canvas_user;
}

public function get_profile_user() {
return $this->profile_user;
}
Expand Down
7 changes: 6 additions & 1 deletion samples/smiley/client/facebookapi_php5_restlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class FacebookRestClient {
public $api_key;
public $friends_list; // to save making the friends.get api call, this will get prepopulated on canvas pages
public $added; // to save making the users.isAppAdded api call, this will get prepopulated on canvas pages
public $canvas_user; // to direct the friends_get call for non-logged in users
public $batch_mode;
private $batch_queue;
private $call_as_apikey;
Expand Down Expand Up @@ -398,7 +399,11 @@ public function &friends_get() {
if (isset($this->friends_list)) {
return $this->friends_list;
}
return $this->call_method('facebook.friends.get', array());
$params = array();
if (isset($this->canvas_user)) {
$params['uid'] = $this->canvas_user;
}
return $this->call_method('facebook.friends.get', $params);
}

/**
Expand Down

0 comments on commit 797b37a

Please sign in to comment.