I am very entry level php. I am fairly proficient in wordpress and I have created some simple plugins. My situation is, I would like to recreate google's way of displaying a wikipedia article. I would like to be able to use a shortcode with the person's name and have it return the same results google would return and styled the same way just on my wordpress website. I know Wikipedia has an api that allows for search and display, I am just trying to wrap my head around the process. If someone could point me in the right direction of how this would be achieved in php or wordpress I would really appreciate it. I know there are some similar questions on here about the wiki api but I would like to hear some different approaches to finding the best way to achieve what google is doing.
If you don't know what I am talking about, try googling someone famous who would have a wiki article and it will display on the right hand side of the screen with their photo and their info in a very nicely displayed box. Can this overall page info be queried all at once, or does each piece of information have to be queried from wiki and then displayed that way with css?
Forgive me if this is to vague or has already been covered. I am very interested in peoples logic to approaching this situation. Any information on this would be very helpful.
You'll be lucky if this doesn't get downvoted to hell, but I'll try and give you at least a basic run-through.
There are two ways to approach this. AJAX or PHP. The PHP method is a little more complicated to wrap your head around (at least for me anyway).
PHP
First, you should sit down and REALLY read the Wikipedia API manual and sources. The people behind Wikipedia have put a ton of effort into it and wouldn't have done so without giving you information on how to use their system. Don't be intimidated--it's really not that hard.
Second, after you've read the API, you'll know what this url means.
http://en.wikipedia.org/w/api.php?format=json&action=query&titles=Main%20Page&prop=revisions&rvprop=content
A method that might work without using CURL, which can be very confusing, is file_get_contents().
So set the query string parameters for the api, and use them like so:
$api_call = file_get_contents('http://en.wikipedia.org/w/api.php?format=json&action=query&titles=Main%20Page&prop=revisions&rvprop=content');
$api_data = json_decode( $homepage );
Now you should have an array that you should easily be able to manipulate and place into your site.
jQuery/AJAX
Way easier in my opinion, and you have the added bonus of some user manipulation:
$.ajax({
type: 'GET',
url: 'http://en.wikipedia.org/w/api.php?format=json&action=query&titles=Main%20Page&prop=revisions&rvprop=content'
}).done(function(data){
var d = $.parseJSON( data );
$('div.data-holder').html( 'foo'+d.bar );
});
None of this is tested. Just meant for a general idea. Hope this helps.
Related
I'm doing some research before I start a project, and I want to know what the best method of going about this project is before I begin. Any help I can get would be much appreciated, and I'd be happy to provide more information if necessary.
Basically, I'll be given a number of extremely high resolution images to display to users. I want to create an interface whereby the user can scroll around the image and zoom in, as well as hover over parts of the picture and receive some information about that specific location. Also, I would really, really like it if I could do it without using Flash in any way, both because I don't like Flash and because it wouldn't work on i-devices.
Here's an example of the zooming capability that I'm looking for, and here's an example of the hover capability that I'm looking for (sorry they're both biblical manuscripts, don't mean to get religious on y'all, these were the best examples I could find!)
Anyway, so far I've found this spiffy script for zooming, but I haven't found anything for hovering yet (another example of what I'm looking for is something like when you tag someone in a picture on Facebook - if you hover over their face, their name pops up). And to make things all the more difficult, I have to figure out how to make them play nice, so zooming in doesn't break the hovering capabilities.
So my questions are...does anyone have any experience with anything like this? Do you have any suggestions for projects (open source is far preferred) that allow for this kind of thing? I'd really appreciate any help you fine people can give me! I'll be publishing my findings and code afterwards.
I think the technology behind Google Maps (and other such technology) would be the way to go. With Google Maps API you can use your own custom tiles instead of the map tiles. You could then set boundaries on the map to stop the user navigating away from your available imagery. Lastly, you can use the API to specify the coordinates for polygons on the "map". These polygons are great as the allow you to have hover/click events which should provide you the functionality you're after.
A good article I found on something similar to what you're after can be found here: http://forevermore.net/articles/photo-zoom/
Hope this provides some direction and sounds like a fun project that you're about to embark on :)
I'm trying to traverse the whole PhoneGap thing to get a native app up and running. I am completely fine with creating html5 markup for the actual app, what I need help with is trying to pull in dynamic content from a website. In particular, there is some content on our website that also needs to be in the app. We use a program call Expression Engine that handles all of our content. The content that I would need to pull over would be:
Sermon Videos
Sermon Series
Locations
Plain text content
The majority of the app will be local, but there are some dynamic needs as you can see. I've read a couple things that say "JSON" is the way to go, but it looks pretty complicated as I'm not quite familiar with AJAX. Is this the only way or are there any options or resources anyone can point me to that might help. I'm not even sure if that method would work for our website. I appreciate any help you can provide.
They are correct. What you need to look into is AJAX/JSON and how to present your data to your app using these technologies.
Expression Engine would actually be quite a good choice for this as its template system is quite flexible. There are even add-on modules for delivering your content as JSON if you want t go that route.
A quick google led me to: http://samcroft.co.uk/2011/updated-loading-data-in-phonegap-using-jquery-1-5/
It's a bit more than you need since you will have your content in an existing CMS instead of creating a new database to store the data, but the concepts will hold true and I am sure you will be able to use it to find more tutorials that suit you better.
I'm attempting to put together a little mashup with some twitter APIs. However, the whole area is new to me (I'm more of an embedded developer dabbling). And frustratingly, every tutorial I am trying in Php is either out of date, not doing what it claims to do, it or is broken.
Essentially, I just want a nice bit of example code - say, an HTML file, a connection.js for the JQuery magic, and a php file - 'getsearch' which contains the relevant Curl calls to the API to just return the results for a given search term.
Followed the tutorial to the letter at
http://www.reynoldsftw.com/2009/02/using-jquery-php-ajax-with-the-twitter-api/
and even downloaded the guy's code and chucked it on my webserver, but it just seems to sit there.
I'm relatively competent at php and html, but it's the Curl and the JQuery side of things which is new to me, and would appreciate any thoughts, links, or code suggestions. I've attempted reading the API - but even that seems sparse - and several links are broken to their own tutorials, so that's put me off a bit for now.
Finally found a working one.
http://papermashup.com/using-the-twitter-api/
This tutorial (or just the php file at http://greenservr.com/projects/twittersearch/TwitterSearch.phps) has the basics including php, jquery and curl to get something back from the twitter API). Finally have something going, so now can expand and extend :)
check the link http://webhkp.wordpress.com/2010/04/13/twitter-api-search-follow-tweet/. this is a great post i found and really helpful for me. hope you fined something helpful here.
Trying to learning some more PHP. Here is what I'm after.
Essentially, I would like to search a website and return data to my own website.
Add a few keywords to a form.
Use those keywords to query a website such as monster.com for results that match the keywords entered.
Grab that data and return it to my own website.
How hard is something like this? I acknowledge the above outline is oversimplified but any tips you can offer are much appreciated.
If you're querying a site that has an API designated for this kind of functionality, you're on easy street. Just call the API's appropriate search function and you're all set.
If the site you're querying doesn't have an API, you still might be able to search the site with an HTTP GET using the right parameters. Then you just need to scrape through the file for the search results with your script and a few regex functions.
Here's a little tutorial on screen scraping with PHP. Hopefully that will be of some help to you. The trouble with this is that in general if the site hasn't made it easy to access their data, they might not want you to do this.
Enter Yahoo Query Language (yql). It's a service that let's you use things like xpath to get data from websites and put them into an easy to use xml or json format. The language is similarly structured to sql (hence the name).
I've used it for other sites to build rss feeds for sites that didn't have it and it was pretty easy to learn.
http://developer.yahoo.com/yql/
Anyone know a good tutorial of how to make the status bar found in the new facebook? the one on the bottom. looks really cool
i was thinking it was written in either ajax or jquery. but not sure.
Here are some useful links/plugins that might help you:
Positioning the footer
Enable drag/drop of things (like applications)
Tooltip (when hover)
And for the interaction with the server (for new events etc.) you might use the AJAX functionality in jQuery:
In order to have it always be in the bottom, that is more of CSS than javascript.
I think you would get better answers if you were more specific. For example, I would want the answer to revolve around as to how the chatroom works on facebook. Is the javascript request being sent every second to check for new messages? or is there another protocol being used in order to have instant messages?
It's not clear what your are looking for: bar's design or it's functionality. If your are speaking about design you should look into css positioning (absolute). If it's about functionality i suppose that there is some kind of ajax javascript which checks every x seconds if there is change of state, and if there is go deeper and find out what to load.
Why not just download the Facebook source code and take a look at how they do it? They open sourced a lot of the stuff they use/created/enhanced.
Soh Tanaka just put out a great step-by-step tutorial on how to re-create the Facebook Status Bar:
Here's another good starting point: http://www.ben-griffiths.com/project/jquery-position-footer/. If I remember correctly it works in FF & IE & Safari
I looked through the jQuery plugins, and Googled the topic for you. All I could find was this which isn't exactly what you want, but it is a good place to start. With some style changes, and a little tweaking it could easily look exactly like the Facebook bar.
Not sure that this is the type of answer you were looking for, but i've been looking for the same thing and this code seems to at least show how it's done.