-
Notifications
You must be signed in to change notification settings - Fork 3
Methods Colors
brianhaveri edited this page Sep 14, 2010
·
9 revisions
Method | Description | Parameter | Returns |
---|---|---|---|
color |
Get a single color | string $hex OR array $query
|
array |
colors |
Get multiple colors | array $query
|
array |
colors_top |
Get top colors | array $query
|
array |
colors_new |
Get new colors | array $query
|
array |
colors_random |
Get random clors | [none] | array |
For color methods, the parameter $query
array can include the following keys:
format
jsonCallback
-
lover
– Not available forcolor()
-
hueRange
– Not available forcolor()
-
briRange
– Not available forcolor()
-
keywords
– Not available forcolor()
-
keywordExact
– Not available forcolor()
-
orderCol
– Not available forcolor()
-
sortBy
– Not available forcolor()
-
numResults
– Not available forcolor()
-
resultOffset
– Not available forcolor()
More information on $query
keys and return values at the ColourLOVERS.com API page
// Single color: simple query require_once('ColourLovers.php'); $c = new ColourLovers; $simple_result = $c->color('FF0000'); print_r($simple_result); /* Array ( [@attributes] => Array ( [numResults] => 1 [totalResults] => 1 ) [color] => Array ( [id] => 176 [title] => Red [userName] => kira [numViews] => 17664 [numVotes] => 3 [numComments] => 127 [numHearts] => 5 [rank] => 50 [dateCreated] => 2005-01-07 20:46:44 [hex] => FF0000 [rgb] => Array ( [red] => 255 [green] => 0 [blue] => 0 ) [hsv] => Array ( [hue] => 0 [saturation] => 100 [value] => 100 ) [description] => [url] => http://www.colourlovers.com/color/FF0000/Red [imageUrl] => http://www.colourlovers.com/img/FF0000/100/100/Red.png [badgeUrl] => http://www.colourlovers.com/images/badges/c/0/176_Red.png [apiUrl] => http://www.colourlovers.com/api/color/FF0000 ) ) */
// Single color: advanced query require_once('ColourLovers.php'); $c = new ColourLovers; $advanced_result = $c->color(array('hex'=>'0099FF', 'format'=>'json')); print_r($advanced_result); // Results structure matches structure of $simple_result in previous example
require_once('ColourLovers.php'); $c = new ColourLovers; $results = $c->colors(array( 'keywords' => 'sky+cloud', 'orderCol' => 'numVotes', 'sortBy' => 'ASC' )); print_r($results);