How to get all links and (some of) the link pages categories for a Wikipedia page? - wikipedia-api

Is it possible for a given Wikipedia page (e.g. Dolphin) to get all links and for every link its categories (at least some, let's say 5 for every link)?
I want to do this in a single query/API call
I tried:
https://en.wikipedia.org/w/api.php?action=query&titles=Dolphin&generator=links&prop=categories&gpllimit=20
this returns the links, but only categories for one link.

I think your query has to work, but shows only 10 categories totally for the whole query because cllimit=10 by default. If you set cllimit=3 again 3 categories will be returned for the whole query:
https://en.wikipedia.org/w/api.php?action=query&titles=Dolphin&generator=links&prop=categories&gpllimit=20&cllimit=3
But: if use cllimit=max you will get the categories for every link:
https://en.wikipedia.org/w/api.php?action=query&titles=Dolphin&generator=links&prop=categories&gpllimit=20&redirects=true&cllimit=max
Also do not forget to use &redirects=true to resolve redirected links, because these pages are without categories.

Related

How to get solr results with atmost one document from each website

I am using solr 4.10.3. I have crawled some documents from web. Now when I query there appears one thing that I do not want. That is: more than one results are show from one website.
What I want is that atmost one result should be shown from each website in results.
Use grouping on host or whatever else you have that uniquely identifies a website: https://cwiki.apache.org/confluence/display/solr/Result+Grouping
group=true&groups.field=host

Concrete5 - unique block on every page

I have a block that displays the number of clicks on the page it is installed.
I want to display that block on every page.
I have tried creating a stack and then including that stack into a global area. The problem is that when the stack is included it includes the same block on every page.
So instead of having different blocks on every page, I have the same block on every page. That results in counting the clicks on all pages instead of only the current one.
How can I include a block on every page, but each having an unique ID as it has when added manually?
Thanks.
There's no way to have a unique block on every page without adding it manually. Even if you make it a "page type default", you'll end up with a shared block ID until you make the first edit (at which point it'll get it's own ID). And if you hardcode into the page's PHP code, it won't have a block ID at all.
With that being said, I don't know why you need a unique block ID. Obviously, each page is going to have a unique ID. So your block should be able to store clicks (I'm not sure exactly what you mean here, but it's probably irrelevant) against the page ID (collection ID in c5 parlance), and retrieve it against that, too.
Edit:
Considering your comment, and based on my understanding of what you're trying to do, there's no reason why you can't combine the block ID (which will, as you say, be duplicated across pages, but will be different on each block ON a page) and the page ID. So if you place two blocks in a stack, they'll get IDs 1 and 2. They'll have IDs 1 and 2 on every page the stack is own. So when you're trying to "record" whatever data they product, you combine the bID with the cID to get 1-103 and 2-103, and 1-4719, etc.
Edit 2:
So if your difficulty isn't so much "keying" the data, but physically storing the data, then see jordanlev's comment below. You won't be using the $btTable table as that's keyed off the bID. Instead you'll use db.xml to create a new table which can take your new key, and whatever other data you want to store. It's then your responsibility to query and update it with Loader::db(). See his block, or see the core's "survey" block for examples of how to manage your own db table.

facebook shares count not accurate

may i know why this three urls return difference of count?
https://www.facebook.com/plugins/like.php?href=http://www.rotikaya.com/iqram-dinzly-tinggalkan-jalan-jalan-cari-makan-kerana-takut-gemuk/&layout=standard&show_faces=false&width=300&action=like&colorscheme=light&height=30
https://graph.facebook.com/?id=http://www.rotikaya.com/iqram-dinzly-tinggalkan-jalan-jalan-cari-makan-kerana-takut-gemuk/
http://api.facebook.com/restserver.php?method=links.getStats&format=json&urls=http://www.rotikaya.com/iqram-dinzly-tinggalkan-jalan-jalan-cari-makan-kerana-takut-gemuk/
(deprecated but more accurate)
The Graph link is intended to reflect the number a like button would show, which is an combination of several metrics.
The getStats endpoint does a more detailed breakdown. If you look at the total value on it, you'll see they match up.
https://graph.facebook.com/?id=http://www.imdb.com/title/tt0117500/
This displays total of likes and the deprecated shares as a whole
http://api.facebook.com/restserver.php?method=links.getStats&format=json&urls=http://www.imdb.com/title/tt0117500/
This one displays all the data, as you can see if you add the like count and share count it is just the same with the previous URL

Values between pages with Apex

I tried looking for an answer, but everything I found seemed too high level. I am a college student who's working on a database project. We need to use apex (oracle) to shred data from an open API source. You can see what me & my team are working on here: http://bit.ly/Jvt4av.
I have listing of movies with links. Those links go to another page that is supposed to show all sorts of details for that movie.
I have successfully passed the movie_id variable between the list and the detail page, but I am stumped now. I need to show the movie's details and I don't want to use reports or forms because they're too ugly to show this kind of info. I want to be able to show the data with HTML. So, my questions are:
Where/how do I query the database, so I can use the results in HTML?
How do I display those results in HTML?
Thank you!
Well, if you have the movie ID then you can use it to query the database and get all the other details from the database. If you want to render those details using just plain HTML then a PL/SQL region in conjunction with some htp.p calls will do the job. For example:
for x in (select * from movies_details where id=<MOVIE_ID>) loop
htp.p('<h1>' || x.movie_title || '</h1>');
end loop

Google Places API: Using Multiple Name Parameters in the Places Search

I've been reading the documentation at: http://code.google.com/intl/nl/apis/maps/documentation/places/#PlaceSearches
But How do I modify the Place Search Request (shown below) so that I can limit the results to specific businesses only.
https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=AIzaSyAiFpFd85eMtfbvmVNEYuNds5TEF9FjIPI
For example in the above code it hastypes=food&name=harbour as two of the parameters. How can I include just "bakery" and "cafe" (both are supported list types) as the types parameter and then include multiple name parameters as well.
In bigger cities it may come back with 20 or so results, but I want to limit it to a handful of businesses that I have agreements with and just show their names on the map. I don't want Starbucks to come back so I want to restrict it to just the 8-10 businesses that I have the agreements with. Their names will be stored in a database so I can easily retrieve them and pass them into the HTTP URL, but I don't know how to do multiple names and get them all to show up on the map at the same time.
Any links to tutorials that can help or your ideas and suggestions would greatly help!
You can include types "bakery" and "cafe" by modifying your request parameter types=food|bakery|cafe add more types separate by "|" operator
for supported type list refer Link