PHP version for SDK

Started by Javy9 replies26 views
JavyOriginal post
#1

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
Javy
#3

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)),
);
Felix_Geisendorfer
#4

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

Javy
#5

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();
Felix_Geisendorfer
#6

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)

Javy
#7

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
Javy
#8

Any thoughts on how to proceed?

Felix_Geisendorfer
#9

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!

Javy
#10

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