} elseif ($response->person->messages[1]->type == "quote") { $attachments = array(['fallback' => $message, 'color' => '#ff6600', 'title' => $motivation]); } $data = json_encode(array("channel" => $channel, 'text' => $message, "attachments" => $attachments)); $ch = curl_init("https://hooks.slack.com/services/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"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Download the given URL, and return output $output = curl_exec($ch); // Close the cURL resource, and free system resources curl_close($ch); } else { if ($trigger_word == "goalstatus") { $params = array("slack_user_id" => $slack_user_id); $response = $client->checkGoalStatus($params); $message = ""; $goal_met = ""; $color = ""; $attachments = array(); if (!empty($response->goal->goalStatusList)) { if (count($response->goal->goalStatusList) > 1) { $i = 1; foreach ($response->goal->goalStatusList as $value) { if ($value->goal_met == false) { $goal_met = "no"; } elseif ($value->goal_met == true) { $goal_met = "yes"; } $message = "*Goal #" . $i . "* "; $message .= $value->target . " " . $value->units . " " . $value->period . ". From " . date("d/m/Y", $value->period_start / 1000) . " to " . date("d/m/Y", $value->period_end / 1000) . ": ";