-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetColorName.php
60 lines (45 loc) · 1.55 KB
/
getColorName.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
function getApiResponse($color = '#ffffff'){
$url = 'http://chir.ag/projects/name-that-color/#CFED61';
$html = file_get_contents($url);
echo $html;
$results = json_decode($html,true);
return $results;
}
try{
echo '<pre>';
echo print_r(getApiResponse(), true);
echo '</pre>';
/* $result = getApiResponse($destination);
$result = getNextStop($result);
echo displayNextStop($result);
echo '<br></br>';
$slack_url = 'https://hooks.slack.com/services/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';
$channel = '#general';
$username = 'Tram Station';
$message = getPayloadMessage(displayNextStop($result));
$icon = ':railway_car:';
$data = json_encode(array(
"channel" => $channel,
"username" => $username,
"text" => $message,
"icon_emoji" => $icon
));
$curl = curl_init($slack_url);//Set up the url to target
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, array('payload' => $data)); //Set up data to transfer
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); //Force curl to every server type (HTTPS included)
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //Return the outputting not displaying it
//$return = curl_exec($curl);
if( $return === false)
{
echo 'Erreur Curl : ' . curl_error($curl);
}
else
{
echo 'L\'opération s\'est terminée sans aucune erreur<br>'.$return;
}
curl_close($curl);*/
}catch (Exception $e) {
echo 'Exception reçue : ', $e->getMessage(), "\n";
}