- Code: Select all
Archived Post
Hi,
I'm having some issues setting metadata with the PHP API.
Just to test it out, I'm using the same values in the example:
- Code: Select all
apiObj = new OpenTokSDK(API_Config::API_KEY, API_Config::API_SECRET);
$role = RoleConstants:: PUBLISHER;
$metadata = '{"username": "bob", "color": "Blue"}';
$token = $apiObj->generate_token($sessionid,$role);
This works fine, because I'm not pushing the metadata in to the generate_token method. But if I change this to include the metadata like so:
- Code: Select all
$token = $apiObj->generate_token($sessionid,$role,$metadata);
I get the following error when trying to connect:
Exception: 1004:: Invalid authentication information passed in Session.connect(). Failed to parse the token: Failed to parse token: too many values to unpack
I had a look at the SDK to see was I calling the method wrong, and it seems that, unlike in the tutorial, the method is actually called with the metadata as the fourth argument, rather than the third.
- Code: Select all
public function generate_token($session_id='', $role='', $expire_time=NULL, $connection_data='')
So, I tried changing my call to the generate_token method to:
- Code: Select all
$token = $apiObj->generate_token($sessionid,$role,null,$metadata);
But that just gave me the exact same error.
For reference, I'm using SDK version tbphp-v0.91.2011-08-07 and loading the Javascript API on the page from http://static.opentok.com/v0.91/js/TB.min.js and as I mentioned at the start, everything works fine if I don't pass any metadata with the generate_token request.
So is this a bug, or am I just missing something really obvious?