PHP version for SDK

Archived from the Transloadit support forum. Originally posted on February 22, 2011; details may be outdated, see our docs for current behavior. Original thread

I’m using PHP 5.2.13 and I keep getting “Unsupported operand types on line 25 of TransloaditRequest.php”. I’m guessing this might be because I’m on an older version of PHP?

Here is the code:

$transloadit = new Transloadit(array(
'key' => 'MY_KEY',
'secret' => 'MY_SECRET'
));

foreach(...){
  $response = $transloadit->createAssembly(array(
    'params' => array(
      'steps' => array(
        'import'=>array('url'=>$url),
        's3store'=>array('path'=>'thumbs/' . $id . '${file.meta.width}_${file.urlName}')
    ),
    'template_id' => 'MY_TEMPLATE_ID',
    'notify_url' => 'MY_NOTIFY_URL'
  )
));
} // end foreach

Hi,

I don’t see anything obvious wrong with your code, and your PHP version should be compatible.

However, I’m wondering if you’re using the latest version of our plugin from github? There is nothing on line 25 in TransloaditRequest.php right now:

https://github.com/transloadit/php-sdk/blob/master/lib/transloadit/TransloaditRequest.php#L25

--fg

Sorry. They should have said line 35. I downloading the src again to make sure I have the latest and greatest.

It looks like the offending line is

$params['auth'] = $this->params['auth'] + array(
  'key' => $this->key,
  'expires' => gmdate('Y/m/d H:i:s+00:00', strtotime($this->expires)),
);

Could you add a debugging statement before this line when you retry?

print_r($this->params['auth']);

It seems like the TransloaditRequest object might not be configured properly. Again, your code looks right, so this is strange. Greatly appreciated!

--fg

Sure.

print_r($this->params); // prints Array ( ) 
print_r($this->params['auth']); // prints nothing

If I add this line above the array addition, then everything seems to work. The problem seems to be that $this->params[‘auth’] is not an array and PHP doesn’t like adding an array to undefined.

$this->params['auth'] = array();

Ok, I see one problem in your code now. notify_url / template_id need to go into your ‘params’ key, not on the same level.

Can you try that?

(Also your import / store steps are missing a robot key, but that couldn’t cause the error)

Sure. Unfortunately the same issue:

Unsupported operand types in TransloaditRequest.php on line 35

Debug:

print_r($params); // Array ( [auth] => Array ( ) )
print_r($this->params); // Array ( )

New code:

$transloadit = new Transloadit(array(
'key' => 'MY_KEY',
'secret' => 'MY_SECRET'
));

foreach(...){

$response = $transloadit->createAssembly(array(
  'params' => array(
    'template_id' => 'TEMPLATE_ID',
    'notify_url' => 'NOTIFY_URL',
    'steps' => array(
      'httpimport'=>array('url'=>$url),
      's3export'=>array('path'=>'thumbs/' . $id . '${file.meta.width}_${file.urlName}')
    )
  )
));
} // end foreach

Any thoughts on how to proceed?

Hi Javy,

I think I fixed your problem in: https://github.com/transloadit/php-sdk/commit/REDACTED

So please download the latest version of the SDK and try again.

I’m really sorry about this. I previously made a chance needed by another customer, but unfortunately that broke the common use case. However, since it worked for the previous customer I initially assumed there was a problem with the way you’re using the library.

Sorry about that, hope it’s working for you now.

Let me know if there is anything else I can help with!

Thanks for your help. That fixed the problem. Appreciate it!