URL convert into guzzle request

Viewed 106

i need to convert this URL into guzzle request

explorer/?method=GET&path=930657230472626%2Fratings%3Ffields%3Dopen_graph_story%2Creviewer&version=v3.2&classic=1

the only problem is how to set multiple values for fields param as you can see it's take two values

fields=open_graph_story,reviewer

so how i convert this into guzzle request here is request which i made so far

 $this->client->request('GET', "/URL", [
      'query' => [
          'fields' => ['open_graph_story', 'reviewer']
       ],
 ]);
1 Answers

The fields parameter value is just a comma-separated string of field names, so you want to use

'fields' => 'open_graph_story,reviewer'

(With 'fields' => ['open_graph_story', 'reviewer'] you would get something like
…&fields[0]=open_graph_story&fields[1]=reviewer in the resulting URL, but the API just wants one value.)

Related