here is the documentation for the database I'm trying to use: https://www.igdb.com/api/v1/documentation
I requested a token from them and it was granted.
This URL works for me (I've written "redacted" in): https://www.igdb.com/api/v1/games?token=redacted
and it returns the following:
{"games":[{"id":1,"name":"Thief II: The Metal Age","slug":"thief-ii-the-metal-age","release_date":"2000-03-21","alternative_name":null},{"id":2,"name":"Thief: The Dark Project","slug":"thief-the-dark-project","release_date":"1998-11-30","alternative_name":null},{"id":3,"name":"Thief: Deadly Shadows","slug":"thief-deadly-shadows","release_date":"2004-05-25","alternative_name":null},{"id":4,"name":"Thief","slug":"thief","release_date":"2014-02-25","alternative_name":"Thief 4"},{"id":5,"name":"Baldur's Gate","slug":"baldur-s-gate","release_date":"1998-11-30","alternative_name":null},{"id":6,"name":"Baldur's Gate II: Shadows Of Amn","slug":"baldur-s-gate-ii-shadows-of-amn","release_date":"2000-09-24","alternative_name":null},{"id":7,"name":"Jagged Alliance","slug":"jagged-alliance","release_date":"1994-06-02","alternative_name":null},{"id":8,"name":"Jagged Alliance: Deadly Games","slug":"jagged-alliance-deadly-games","release_date":"1995-01-01","alternative_name":null},{"id":9,"name":"Jagged Alliance 2","slug":"jagged-alliance-2","release_date":"1999-07-23","alternative_name":null},{"id":10,"name":"Jade Empire: Special Edition","slug":"jade-empire-special-edition","release_date":"2005-04-12","alternative_name":null},{"id":11,"name":"Vampire: The Masquerade - Bloodlines","slug":"vampire-the-masquerade-bloodlines","release_date":"2004-11-16","alternative_name":null},{"id":12,"name":"Vampire: The Masquerade - Redemption","slug":"vampire-the-masquerade-redemption","release_date":"2000-06-07","alternative_name":null},{"id":13,"name":"Fallout","slug":"fallout","release_date":"1997-09-30","alternative_name":null},{"id":14,"name":"Fallout 2","slug":"fallout-2","release_date":"1998-09-30","alternative_name":null},{"id":15,"name":"Fallout 3","slug":"fallout-3","release_date":"2008-10-28","alternative_name":null},{"id":16,"name":"Fallout: New Vegas","slug":"fallout-new-vegas","release_date":"2010-10-19","alternative_name":null},{"id":17,"name":"Fallout Tactics: Brotherhood Of Steel","slug":"fallout-tactics-brotherhood-of-steel","release_date":"2001-03-15","alternative_name":null},{"id":18,"name":"Max Payne","slug":"max-payne","release_date":"2001-07-23","alternative_name":null},{"id":19,"name":"Max Payne 2: The Fall Of Max Payne","slug":"max-payne-2-the-fall-of-max-payne","release_date":"2003-10-24","alternative_name":null},{"id":20,"name":"BioShock","slug":"bioshock","release_date":"2007-08-21","alternative_name":null},{"id":21,"name":"BioShock 2","slug":"bioshock-2","release_date":"2010-02-09","alternative_name":null},{"id":22,"name":"System Shock 2","slug":"system-shock-2","release_date":"1999-08-11","alternative_name":null},{"id":23,"name":"System Shock","slug":"system-shock","release_date":"1994-09-22","alternative_name":null},{"id":24,"name":"UFO: Enemy Unknown","slug":"ufo-enemy-unknown--1","release_date":"1994-01-01","alternative_name":null},{"id":25,"name":"X-COM: Terror From The Deep","slug":"x-com-terror-from-the-deep","release_date":"1995-01-01","alternative_name":null}]}
What I'm trying to do is figure out how to search by title. For example, if I wanted only games that have the term "Zelda" in it, how would I format the URL properly?
I've tried:
https://www.igdb.com/api/v1/games&q=zelda?token=redacted
which returns "forbidden".
I've also tried
https://www.igdb.com/api/v1/games?token=redacted&q=zelda
which returns that same exact list of games above, as if completely unaffected by the "Zelda" term.
Can anyone give advice on how to properly format this URL for performing a search based on Game Title? Thank you!
The first query parameter should be passed with a "?" and the following ones each with "&".
The documentation of the API says that you should query /games/search instead of /games directly. Please try this.
Although this question relates to a particular Wordpress plugin called the All in One Event Calender by Time.ly it can also be a general PHP related question.
I am trying to modify a theme to use event colours selected in the ai1ec back end and would like to produce a simple HTML colour code - ie "#f2f2f2"
The plugin itself has loads of functions and php shortcodes to pull a wealth of information off each event such as the one listed below.
<?php echo $event->get_category_text_color(); ?> which will print style="color: #f2a011;"
Can also change to print style="background-color: #f2a011;" with the use of $event->get_category_bg_color();
Now the real meat of the question
All I want to do is get that HTML colour so I can also code it into buttons and other visual elements. I have scoured through blogs and code to try and find something that does it to no avail.
What I was wondering is if you could write a filter of some sort to just take the information within the "#f2f2f2" quotation marks. I know it's not called a filter as searches for php filter return information about something completely different - I'm a self taught PHP programmer and so searching for a lot of terms I don't know can be pretty tough!
As pointed above, substr would be a great solution but it wouldn't solve the case where the color code is expressed in this format:
#FFF;
instead of:
#FFFFFF;
Therefore, this regex should do the job quite well:
'/?=#(.*(?=;)))/'
Example:
$matches = array();
preg_match('/?=#(.*(?=;)))/', $event->get_category_text_color(), $matches);
$colorCode = "#{$matches[0]};";
You could use the substr() function like so:
echo substr($event->get_category_text_color(),14,-2);
Which in the example, would return #f2f2f2.
There are a lot of free tools out there to convert from UTM to Lat/Long. Fine enough, but I need to go the other way; from WGS-84 to lat/long-format.
But it's more complicated than that; 'couse I need the result to be in UTM-33 (nordic) zone.
This might sound like a bad idea; why would I like to "force" the zone to 33N, when the geographical point might be laying in another zone ...
Well; the thing is that I already have a database with UTM33-coordinates of every address in Norway.
Those of you that are familiar with UTM # Northern Europe, knows that Norway spans across several zones; from 31 to 36.
(Okay, maybe we only spans from 32 to 36, cause of the strange width of zone 32V, but thats another discussion).
So, back to my problem: all my addresses are already given in UTM-33 format (with negative values when out of range). How can i proceed to get my Lat/Long into UTM-33?
I need a solution in PHP, and after a lot of debugging with "gPoint", I found out it just won't work ...
(gPoint is great to convert from/to UTM, but it will always return the UTM x/y-pair in the "correct" zone block. I don't want that! I need to always get results in zone 33, regardless of what is actual correct..)
I finally found a solution though Proj4 (thanx SlightlyCuban)!
// Conversion from WGS84 to UTM33
$proj4 = new Proj4php();
$projWGS84 = new Proj4phpProj('EPSG:4326');
$projUTM33N = new Proj4phpProj('EPSG:2078');
$result = $proj4->transform($projWGS84, $projUTM33N, new proj4phpPoint($long, $lat));
It is impossible to guess correct format for transformation, and I was struggling for a while ... then I discovered a really handy webpage: http://spatialreference.org. Here I found the definition I needed (EPSG:2078 = "+proj=utm +zone=33 +ellps=intl +units=m +no_defs")
The PHP-implementation of Proj4 needs hard-coded definitions; you cannot pass by a definition ad-hoc. EPSG:2078 was originally missing from Proj4php. Yay; lucky me!
I would therefor recommend to test Proj4 via Node.js and proj4js (see my little demo at http://pastebin.com/1BP8cWpj).
To succeed, I had to fork the Proj4PHP-library, and add a definition file for EPSG:2078 ...
I want to find the country code of my site visitor using the ipinfodb API.
When I try the following, http://api.ipinfodb.com/v3/ip-country/?key=<My_API_Key>&ip=<Some_IP>, it gives the following output:
OK;;<Some_IP>;US;UNITED STATES
How do I filter this output so that it shows only the country code ?
Regards,
Timothy
EDIT:
In reply to Charles,
After searching on google I came to know that the API can be given a 'format attribute as XML' so the following works.
$xml = simplexml_load_file('http://api.ipinfodb.com/v3/ip-country/?key=<My_API>&format=xml&ip=<Some_IP>);
echo $xml->countryCode;
How can I get the same output without the XML argument ?
Thanks
OK;;<Some_IP>;US;UNITED STATES
How do I filter this output so that it shows only the country code ?
I find it curious that you'd be able to invoke SimpleXML, but didn't think of explode, which will turn a string in into an array, splitting on the given delimiter. In this case, we need to explode on ;:
$string_data = 'OK;;127.0.0.1;US;UNITED STATES';
$sploded_data = explode(';', $string_data);
print_r($sploded_data);
echo "\nCountry code: ", $sploded_data[3], "\n";
This should emit:
Array
(
[0] => OK
[1] =>
[2] => 127.0.0.1
[3] => US
[4] => UNITED STATES
)
Country code: US
You may wish to review the rest of the string manipulation functions to see if there's any other interesting things you may have missed.
The above answer isn't particularly helpful, because the server output is only static if you explicitly specify the same IP address every time. If you hardcode a location request for a particular IP address, it's going to the be the same every time. What's the point?
Do this instead
Install the PHP class for their API. PHP Class
Play around with the PHP sample found here; save it as its own webpage and observe the results. Let's call it "userlocation.php." Please note that the fields will be null if you load from localhost.
Okay, the trick to parse this output is array_values(). Took me forever to figure this, but eventually I stumbled upon this.
So...
$locations = array_values($locations);
echo $locations[n],"<br />\n";
echo $locations[n+1],"<br />\n";
etc.
Whatever element you need, you can get in this way -- and it's dynamic. The code will return whatever country pertains to the user's IP address.
One last note. Take care to paste your API key into the class file and not into userlocation.php. The class file variables are protected, which is a good thing.
Anyway, I'm no expert; just thought I'd share what I've learned.
I want to create coupon codes that users can remember easily. My idea is something like:
squirrel45
nantucket23
That is, a real word chosen randomly from a long dictionary list (preferably compiled for this purpose) combined 2 random digits. My questions are:
Where can I find such a dictionary list?
Do you see any problems with the system? (security is not ultra important here, just something reasonable is fine)
Can you suggest any good improvements or alternatives?
Fwiw I am not crazy about the Markov word generators because I think their idiosyncrasies would be too hard to remember. I'd like a client to be able to keep the code in his head, and tell it to the merchant when he arrives to redeem it.
Thanks,
Jonah
Word lists are easy to find. Make sure you sanity filter them for foul words ;)
Here's a huge word list that can be easily scrubbed:
http://www.scrabble-assoc.com/boards/dictionary/10-15-20030401.txt
From there you can easily load in words into your database and create your coupon code like so:
$coupon_code = $rand_word . rand(20,99);
After you do this, simply store your coupon code in the database and whenever you make a new code, check it against existing codes before you apply it. Even slim odds are possible odds.
More word lists in various formats:
http://scrabble.wonderhowto.com/blog/ultimate-scrabble-word-list-resource-0115617/
5-letter words:
http://homepage.ntlworld.com/adam.bozon/Scrabble5.htm
6-letter words:
http://homepage.ntlworld.com/adam.bozon/Scrabble6.htm
7-letter words:
http://homepage.ntlworld.com/adam.bozon/Scrabble7.htm
8-letter words:
http://homepage.ntlworld.com/adam.bozon/Scrabble8.htm
Sample:
PIKES PIKIS PILAF PILAR PILAU PILAW PILEA PILED PILEI PILES PILIS
PILLS PILOT PILUS PIMAS PIMPS PINAS PINCH PINED PINES PINEY PINGO
PINGS PINKO PINKS PINKY PINNA PINNY PINON PINOT PINTA PINTO PINTS
PINUP PIONS PIOUS PIPAL PIPED PIPER PIPES PIPET PIPIT PIQUE PIRNS
PIROG PISCO PISOS PISTE PITAS PITCH PITHS PITHY PITON PIVOT PIXEL
PIXES PIXIE PIZZA PLACE PLACK PLAGE PLAID PLAIN PLAIT PLANE PLANK
PLANS PLANT PLASH PLASM PLATE PLATS PLATY PLAYA PLAYS PLAZA PLEAD
PLEAS PLEAT PLEBE PLEBS PLENA PLEWS PLICA PLIED PLIER PLIES PLINK
PLODS PLONK PLOPS PLOTS PLOTZ PLOWS PLOYS PLUCK PLUGS PLUMB PLUME
PLUMP PLUMS PLUMY PLUNK PLUSH PLYER POACH POCKS POCKY PODGY PODIA
POEMS POESY POETS POGEY POILU POIND POINT POISE POKED POKER POKES
With that you could generate a coupon code POACH72
Concatenating 2 words will increase the security posture of your system.
e.g. squirrel.nantucket.123
The Diceware page has a couple of long word lists, American and International. It also has a useful description of how to meet various levels of security.