Im getting this error when im trying to use the API exampel for PHP:

Parse error: syntax error, unexpected '[', expeting ')' in line 21.

The line 21 looks like this (i have copyed from the exampel, so there should be no typos.)

$request = json_encode(['request' => $data]);

asked 07 Sep '14, 11:53
c0mplx's gravatar image

c0mplx
2113

Hello,

Could you please send us the whole request that fails to work? It would really help us to investigate.

(08 Sep '14, 04:21) Dmitry Dyudeev Dmitry%20%20Dyudeev's gravatar image

You need convert all [] -> array()

Please, try some like this

pwCall('createMessage', array(
    'application' => PW_APPLICATION,
    'auth' => PW_AUTH,
    'notifications' => array(
            array(
                'send_date' => 'now',
                'content' => 'test'
            )
        )
    ) );
permanent link
answered 19 Dec '14, 08:27
XXXX's gravatar image

XXXX
2.2k6

edited 08 Jan '15, 15:00

Hello, please check your php version(php --version). Root cause can be older php-version because short-array syntax available since php 5.4+

permanent link
answered 08 Sep '14, 11:26
XXXX's gravatar image

XXXX
2.2k6

edited 08 Sep '14, 11:28

did you solved it??? i got the same problem.

permanent link
answered 18 Dec '14, 20:27
sylvestdesign's gravatar image

sylvestdesign
112

Please, see my previous answer. Issue in new php array syntax, please use classic syntax $request = json_encode(array('request' => $data)); or upgrade php interpreter

(18 Dec '14, 20:33) XXXX XXXX's gravatar image

Thanks that solved that error ,

i also go an error in in the line where it says:

pwCall('createMessage', [

do you know how to fix it?

permanent link
answered 18 Dec '14, 23:49
sylvestdesign's gravatar image

sylvestdesign
112

Can you check my answer? And report about results?

(19 Dec '14, 13:45) XXXX XXXX's gravatar image

THANKS . gonna try it out.

permanent link
answered 19 Dec '14, 13:49
sylvestdesign's gravatar image

sylvestdesign
112

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×446
×83
×33

question asked: 07 Sep '14, 11:53

question was seen: 2,595 times

last updated: 08 Jan '15, 15:00