-1
$cm_json = exec('curl -H "Accept: application/vnd.pagerduty+json;version=2" -H "Authorization: Token token="XXXXXXX" -X GET -G  "https://api.pagerduty.com/users/'.$user_id.'/contact_methods/" | jq '.contact_methods[] | select(.label == "Mobile") | .address'');

PHP Parse error: syntax error, unexpected '[' on line 56

Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95

1 Answers1

0

You have a quote issue. Use baskslash before the single quote of the jq filter:

$cm_json = exec('curl -H "Accept: application/vnd.pagerduty+json;version=2" -H "Authorization: Token token="XXXXXXX" -X GET -G  "https://api.pagerduty.com/users/'.$user_id.'/contact_methods/" | jq \'.contact_methods[] | select(.label == "Mobile") | .address\'');
oliv
  • 12,690
  • 25
  • 45
  • Thanks a lot, It's working. – Balapradeep Gullapalli Oct 08 '18 at 09:37
  • When the answer is "you have a quote issue", there is no need to answer. Just leave a comment under the question and flag/vote to close as Off-topic: Typo. This page will be quickly scrubbed from the site (as will any upvote points you receive) because this page is completely useless to researchers.See: [Should one advise on off topic questions?](//meta.stackoverflow.com/q/276572/1768232). – John Conde Oct 08 '18 at 11:33