How to format URL with query parameters for IGDB API? - php
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.
Related
elipsoid area function not giving correct results
I have created a function to return the surface area of a given ellipsoid dimension but i am getting strange results. Here is the function: function elipsoid($a,$b,$c){ $ab=$a*$b; $ab=pow($ab,1.6); $ac=$a*$c; $ac=pow($ac,1.6); $bc=$b*$c; $bc=pow($bc,1.6); $abacbc=$ab+$ac+$bc; $abacbc=$abacbc/3; $prepie=pow($abacbc,0.016); $fourpies=3.1415926535898*4; $elipsoidarea=$prepie*$fourpies; return $elipsoidarea; } If values of $a,$b,$c are all =1 the result is 12.566370614359 which according to the ellipsoid calculator on google is correct. If values of $a,$b,$c are all =2 the result is 13.02034823541 which according to the ellipsoid calculator on google should be 50.26548. I had my teenage daughter help translate this: S≈4π((ab)1.6+(ac)1.6+(bc)1.63)1/1.6 (copy pasted from google hence doesn't look like the equation now lol). Into "idiot" form such that I can understand it. Is the calculation translation correct and/or have I coded it right? I also question how according to google a 4m wide sphere can have a surface area of 50m? Is Google wrong as well as the many sites that have this calculation option?
your doing wrong here, $prepie = pow($abacbc,0.016); It should be, $prepie = pow($abacbc,0.625); As of this, root of 1.6 -> 1/1.6 -> 0.625
How to handle special characters in fuzzy search query
So my solr query is implemented in two parts,first query does an exact search if there are no results found for exact then it goes to the second query that does a fuzzy search. every things works fine but in situations like-->A user enters "burg +" So in exact search no records will come,so second query is called to do a fuzzy search.Now comes the problem my fuzzy query does not understand special characters like +,-* which throws and error.If i dont pass special characters it works fine. But in real world a user can put characters with their search,which will throw an error. Now iam stuck in this and dont know how to resolve this issue. This is how my exact search query looks like $query1="(business_name:$data*^100 OR city_name:$data*^1 OR locality_name:$data*^6 OR business_search_tag_name:$data*^8 OR type_name:$data*^7) AND (business_active_flag:1) AND (business_visible_flag:1) AND (delete_status_businessmasters:0)"; This is how my fuzzy query looks like $query2='(_query_:%20"{!complexphrase%20qf=business_name^100+type_name^0.4+locality_name^6%27}%20'.$url_new.')AND(business_active_flag:1)AND(business_point:[1.5 TO 2.0])&q.op=AND&wt=json&indent=true'; This is the error iam getting Cannot parse ' must~1 *~N': '*' or '?' not allowed as first character in WildcardQuery Iam new to solr and dont know how to tackle this situation. Details of what iam using Solrphpclient php solr 4.9
ok so i see that you are using solrphpclient.You need to make changes in the service.php file so that these special characters get replaced to either blank or what ever you want. This will take care of the problem you are facing $params=str_replace("%", "", $params); $params=str_replace("*", "", $params); $params=str_replace("&", "", $params); you need to put this in the search function or inside you custom function which i assume you are using for the fuzzy query
Smarty dynamic variable issue
Unfortunately, in my current workplace, I have to use Smarty on a project they had before i was employed. Anyway, I am trying to call in a Dynamic html title for each category in the app. So for example, the title used to be pageTitle="{$category} in {$areaname}". However I now want it to be: pageTitle="{html_title}". Within html_title (from db), is a string, for example: "Monkeys in the {areaname}" Where {areaname} could be "jungle". When I output the result, I get: "Monkeys in {areaname}". So to cut a long story short, its not recognizing the variable. It is treating it as a string. I have googled my head off and can't find an answer. I hate smarty! Please help!
Couldn't you just do something like $html_title = preg_replace("/{areaname}/", "jungle", $html_title); after fetching the title from the database?
Structuring a Gdata Spreadsheet query
I am trying to build a Zend_Gdata_Spreadsheets_ListQuery and I can't find any references that explain what the expected query syntax is and what types of queries you can and cannot perform. The closest I have been able to come to finding anything is the [Google Data APIs Client Library (1.41.1)] (https://developers.google.com/gdata/javadoc/com/google/gdata/client/spreadsheet/ListQuery#ListQuery(java.net.URL)), which describes the function setSpreadsheetQuery as follows: setSpreadsheetQuery public void setSpreadsheetQuery(java.lang.String query) Sets the structured spreadsheet query. Parameters: query - the query such as "name = 'Sonja' and state = 'Georgia'" This works just fine if you are looking for a cell whose column title is "name" and that contains the text "Sonja"—and nothing else. I am looking for cells containing "Sonja" as part, of the cell's text. A cell in the "name" column with the value "Sonja the Awesome" for example, would not match the search above. name=Sonya* causes an error and name="Sonya*" returns no results. So, does anybody know where I can find a rundown of what the expected "structure" for the "structured spreadsheet query" is?
Have you tried using regex ? Also, make sure to escape the regex special characters. Something like \bSonja\b
Building Reducisaurus URLs
I'm trying to use Reducisaurus Web Service to minify CSS and Javascript but I've run into a problem... Suppose I've two unminified CSS at: http:/domain.com/dynamic/styles/theme.php?color=red http:/domain.com/dynamic/styles/typography.php?font=Arial According to the docs I should call the web service like this: http:/reducisaurus.appspot.com/css?url=http:/domain.com/dynamic/styles/theme.php?color=red And if I want to minify both CSS files at once: http:/reducisaurus.appspot.com/css?url1=http:/domain.com/dynamic/styles/theme.php?color=red&url2=http:/domain.com/dynamic/styles/theme.php?color=red If I wanted to specify a different number of seconds for the cache (3600 for instance) I would use: http:/reducisaurus.appspot.com/css?url=http:/domain.com/dynamic/styles/theme.php?color=red&expire_urls=3600 And again for both CSS files at once: http:/reducisaurus.appspot.com/css?url1=http:/domain.com/dynamic/styles/theme.php?color=red&url2=http:/domain.com/dynamic/styles/theme.php?color=red&expire_urls=3600 Now my question is, how does Reducisaurus knows how to separate the URLs I want? How does it know that &expire_urls=3600 is not part of my URL? And how does it know that &url2=... is not a GET argument of url1? I'm I doing this right? Do I need to urlencode my URLs? I took a peek into the source code and although my Java is very poor it seems that the methods acquireFromRemoteUrl() and getSortedParameterNames() from the BaseServlet.java file hold the answers to my question - if a GET argument name contains - or _ they should be ignored?! What about multiple &url(n)s?
Yes, you need to URL encode your URLs before you submit them as a parameter to another webservice. E.g. http://google.com Becomes http%3A%2F%2Fgoogle.com If you do that, no special characters like ?, &, = et cetera survive the process that could confuse the webservice. (Not quite sure what you're asking with your second question, sorry.)
everything which starts with url is threated as a new url, so you cannot pass a parameter called url2 as a get argument of url1. Every param name that does not contain a '-' will be treated as input. So if you do ...?file1=...&url1=...&max-age=604800, the max-age will not be treated as input. However, ...?file1=...&url1=...&maxage=604800 here the maxage will be treated as input.