Prerequistes for learning how to code a facebook application - facebook

I am facing a really tough time doing this. I haven't done much on web development before this. I know HTML and dats it. What else do I need to learn in order to start coding a good facebook app (specifically scripting languages like JS, PHP, MySQL etc). I have already created a test application using a web hosting site. Time is of the essence here.

I would pick up Head First Servlets and JSP or Head First PHP & MySQL. They will be your best friends in the process of writing PHP or JSP. Then of course you should learn what's in the Facebook API and how to use it.
You mentioned that time is off the essence, but I simply can't think of a reasonable way by which you can learn PHP or JSP without putting in the grunt work (which takes time). You should definitely do some reading unless you want to make an app that's hacker's paradise.
If you're already familiar with Java, then JSP will feel more natural and probably easier/faster to learn.
P.S. Sorry for the multiple edits... I felt like my wording was a bit off.

Related

Website Data Crawler, posting data and traversal

Although there have been quite some posts on these topic, my question is little bit specific.
I need to parse few website and once done, I need to send some data to it. For example, say website A offers me a search tab, I need to programatically feed data to it. The resulting page might differ based on target site's updates.
I want to code such a crawler. So which tools/language would be best to realize this?
I am already well-versed in java and C, so anything based on these would be really helpful.
I would suggest using phantomjs. It's completely free and Windows, Linux, Mac are supported.
It is very simple to install.
It is very simple to execute using
command line.
Community is pretty big and solving straight-forward
problems is trivial.
It uses JavaScript as the scripting language so you'll be fine, I guess, with your Java background.
You'll have to get familiar with DOM structure. Well, you cannot write a crawler without knowing it (even in case you select completely visual solution).
Everything depends on how frequently the crawler should be executed: PhantomJs is great for long-term jobs. Use something else, visual, like iMacros in case you're looking for one-time solution. It can be used inside Mozilla as an extension (free of charge) and there's a standalone version that costs money.
Cheers

Scala website: create routes

I'm following the Heroku scala tutorial at https://devcenter.heroku.com/articles/scala
I was able to get everything working, but I have absolutely no idea where to go from here. I'd like to avoid using a framework (for now) if I can since the point of this is to learn scala and create a website with it. Their webwords example they list as a followup is completely different from the basic hello world example.
Mainly, I have no idea how heroku/scala/sbt know how to actually start the app and respond to requests since the samples are so different. I've looked at some frameworks and they seem pretty similar in that regard.
I'd really just like to know what the standard method for creating routes is (if there is such a thing). Any other tips about how to create a small MVC framework would also be of great help to me. A lot of the tutorials I see seem to make assumptions about what you already know (e.g. you would already know how to create routes and the like) but I can't find any tutorials that are even simpler.
Ultimately, the purpose of creating any web site, regardless of the technology used, is to offer some sort of content or functionality. You can't just say "I want to create a web site." any more than you could say "I want to build a building."
Once you have defined what the web site is supposed to do, then and only then is appropriate to consider how to implement it. The purpose of most frameworks to provide easy to use solutions to common and often difficult problems. For example, using a web application server like Jetty, Tomcat, or Glassfish trivializes most of the "route" issues. Any time that you save by using available tools can then be reinvested in creating better content.
On the other hand, if you really do want to implement an entire web server from scratch, the place to start is with the basic Hello app. In Hello.apply, you can start by looking at the HttpRequest (JBoss JavaDoc). getURI() will give you the request URL, and you can work out, from there, how to handle the different routes that you want to support.

What do I need to learn before I can start using Lift?

I know Scala. I've used mongoDB, redis, sbt, ... backend stuff.
I know basic HTML, CSS and JavaScript but have never done real web development.
I don't know what AJAX is. I don't really know any frontend stuff.
What should I learn before I start trying to tackle Lift?
If you know Scala, you are pretty much set on the programming side.
On the other hand, Lift requires HTML/CSS templates. In fact, it is completely separate from programming, so that a professional web designer can work on them, while the programmer works on the code. If you can revise your HTML/CSS stuff, it will help.
You don't need to know AJAX -- that part Lift takes care of for you.
So, it seems you are mostly set. I strongly recommend Timothy Perret's Lift in Action, from Manning. Though the book hasn't been released yet, you can get the Manning Early Access Program (MEAP) for it and, as it happens, the whole book has been written already.
If you already know Scala, learn some basics of web development and how Java handles it:
HTTP protocol
Servlets (also know what JSP is)
AJAX

Advice on the aproach for a native iPhone that emulates a web application

I need your advice. We have an already working web resource management application, we use the usal tools html, css, php, mysql, the users logs in, create a new issue and data is saved/retrieved in/from a sever, everything ok.
The thing is that they ask me to develop an iPhone app using objective-c to emulate the functionality. Now, I have some thoughts on this:
One aproach is to just make the ajax optimizations so the website runs like any other iphone web app, honestly not convenient for me, they'll hire a web developer.
The native app could request the web pages, parse html and maybe get the values to display them, lets say ... in a tableView
The last one and wich I thing should be the most "simple" is to call the php scripts that will make requests to the database and get the data without tags.
I've diggen in the said php scripts and discovered that they have embeded html, so, does that mean there's no way to scape from parsing html?
Please give ideas to clear this problem, thanks in advance.
While scraping might seem like a quick and easy way to get the job done, it's one I'd really not recommend using. This is because at any time the HTML served by your web application can and will change, and that will potentially break your application, which will waste a lot of time making little fixes here and there, releasing updates to your app with these fixes and so on.
I'd recommend working with your web app guys to come up with a proper REST API so it makes things easier for you and your iPhone app.
The mix of data/HTML isn't going to be pretty.
You can do some sort of clean up using Objective-C string functions, but the code will be pretty one-off and crufty.
Instead of calling those scripts straight off the server, you might consider adding a second, parser-like PHP script to work as a middleman. You call it, it calls the original script and returns a data structure that you can work with, like JSON.

How do I develop web 2.0 apps with CGI.pm?

A few years ago I did a lot of work with CGI.pm. I'm evaluating using it again for a quick project. Can someone bring me up to speed on the current state of developing with CGI.pm in the "Web 2.0" world? What are the best libraries on CPAN to use with it? Are there clean ways to include jQuery, YUI, other CSS libs, etc, and do some AJAX. There are of course lots of libraries on CPAN but what works and what is commonly used?
We aren't still doing this?
$JSCRIPT<<EOF;
...
EOF
I realize people are going to offer Catalyst as an answer. However, many people may have legacy CGI.pm apps they simply want to enhance. Is starting over really the best answer?
Personally, I'm no fan of Catalyst (too heavy for my taste) or Mason (mixing code and HTML is bad ju-ju), but I do quite well using CGI.pm for input[1], HTML::Template for output, and CGI::Ajax to provide AJAX functionality where called for.
If you're looking at frameworks, you may also want to consider CGI::Application, which is a widely-used and lighter-weight alternative to Catalyst/Mason.
[1] I can't recall the last time I called anything other than $q->param or $q->cookie from CGI.pm. There are still a lot of tutorials out there saying to use its HTML-generation functions, but that's still mixing code and HTML in a way that's just as bad as using here docs, if not worse.
Consider using something more modern, for example Catalyst. It will make your life much easier and you won't have to reinvent the wheel. I understand that it is just a small project, but from my experience many small projects in time become large ones :)
The "web 2.0" apps that I've worked with usually use client-side JavaScript to request JSON data from the server, then use that data to update the page in-place via DOM.
The JSON module is useful for returning structured data to a browser.
As far as including JavaScript, HTML, or whatever in a here doc - that was never a good idea, and still isn't. Instead, use one of the plethora of template modules to be found on CPAN. For a CGI, I'd avoid "heavy" modules like Mason or Template Toolkit, and use a lighter module for quicker startup, such as Text::Template, or Template::Simple.
Yes, you can write perfect web2.0 web applications WITHOUT using any framework on the server side in any language Perl, Python, Java, etc and WITHOUT using any JavaScript libraries/framework on the client side. The definition of web 2.0 is kind of a loose definition, and I'm guessing by web2.0, you mean Ajax or partial page refresh, then all you would really need is to focus on the following:
Know about the XmlHttpRequest object.
Know how to return JSON object from the server to the client.
Know how to safely evaluate/parse the JSON object using JavaScript and know to manipulate the DOM. Also, at least know about innerHTML. InnerHTML is helpful occasioanally.
Know CSS.
Having said that, it's a lot easier to use some framework on the server side, but not because it's required by web2.0 and it's a lot easier to use some JavaScript on the client like jQuery, mootools, YUI. And you can mix-and-match depends on your needs and your tastes. Most JavaScript provides wrapper around the XmlHttpRequest so that it works across all browsers. No one write "naked" XmlHttpRequest anymore, unless you want to show some samples.
It's perfectly possible to write "Web 2.0" apps using CGI.pm, but you'll have to do the work yourself. From what I've seen, the focus in the Perl development community has been on developing successor frameworks to CGI, not on writing helper modules to let legacy apps get bootstrapped into modern paradigms. So you're somewhat on your own.
As to whether to start over, what are you really trying to accomplish? Everyone's definition of "Web 2.0" is somewhat different.
If you're trying to introduce a few modern features (like AJAX) to a legacy app, then there's no reason you need to start over.
On the other hand if you're trying to write something that truly looks, feels, and works like a modern web app (for example, moving away from the page-load is app-state model), you should probably consider starting from the ground up. Trying to make that much of a transformation happen after the fact is going to be more trouble than it's worth for anything but the most trivial of apps.
I agree with Adam's answer, you probably want to use Catalyst. That being said, if you really don't want to, there's nothing preventing you from using only CGI.pm. The thing is, Catalyst is a collection of packages that do the things you want to make Web 2.0 easy. It combines the various templating engines such as Template Toolkit or Mason with the various ORM interfaces like DBIx::Class and Class::DBI.
Certainly you don't have to use these things to write Web 2.0 apps, it's just a good idea. Part of your question is wondering if javascript and CSS frameworks like jQuery, or prototype require anything from the server-side code. They don't, you can use them with any kind of server-side code you want.
For new apps, if you don't find Catalyst to your taste, Dancer is another lightweight framework you may like. There are also plenty of others, including CGI::Simple, Mojo/Mojolicious, Squatting...
Any of these lightweight frameworks can take care of the boring parts of web programming for you, and let you get on with writing the fun parts the way you want to.
If the jump from CGI.pm to Catalyst seems too daunting then perhaps something like Squatting might be more appropriate?
Squatting is a web microframework and I have found it ideal for quick prototyping and for replacing/upgrading my old CGI scripts.
I have recently built a small "web 2.0" app with Squatting using jQuery with no issues at all. Inside the CPAN distribution there is an example directory which contains some programs using jQuery and AJAX including a very interesting [COMET](http://en.wikipedia.org/wiki/Comet_(programming)) example which makes use of Continuity (which Squatting "squats" on by default).
NB. If required then you can later "squat" your app onto Catalyst with Squatting::On::Catalyst
There is also CGI::Ajax.