I'm developing android app. It's some sort of social network. Where user can add friend and some few stuff. I've been working on php for quite a time now. But android is totally new for me. The app will be served by a web service.
My android skill are not good. So total time I spend on working on android part is more. So I'm thinking is there any framework that can be used to serve my application. With this I can reduce time to implement web service. I know some of framework but as I have not worked with them, I don't know how much they can be extended to fit in my need. OR should I implement it by my own without any framework ?
All the suggestions, advises will be extremely helpful.
In my opinion you should definitely go with a framework, so you can concentrate more on developing the Android app.
Important is, that you choose your backend framework wisley. So it should be a lightweight and/or RAD (Rapid Application Development) framework, which enables you to use code generation for common patterns to get startet very fast.
I can recommend Ruby on Rails. If you want to stick with PHP, then my recommandation would be Symfony 2 or Kohana. Using those frameworks, you should concept and implement an API, preferably RESTful, which provides your Android application with data and can be used later on for all other kind of mobile apps or third party applications.
If you go with Symfony 2 you can have a look for the FOSRestBundle - a bundle which provides tools to create a RESTful API.
Further on, Symfony 2 comes with a very good documentation - including a getting started section, as well as a cookbook.
So,... happy coding. :)
I don't think a framework is really needed here. An efficient way to communicate between your server and Android is through the JSON data format. It's smaller than XML, but it's just as easy to use.
For example, to request the list of friends, you could send a request like this:
http://www.example.com/android.php?do=friends
And send your authentication cookies just like with the desktop site. A response would look like this:
{
"friends": [
{
"name": "John Lua",
"age": 19,
"friends_since": 32423434
},
...
]
}
In the production version, you can of course leave out the indentation and other spacing.
It is trivial to generate this output in PHP, but if you want, you can use a function like this: http://www.php.net/manual/en/function.json-encode.php
Parsing it again in Java (on Android) can be done with a library: http://json.org/java/
You would request this response with a normal web request in Java. You can find information on web requests with cookies here: http://www.hccp.org/java-net-cookie-how-to.html
Serverside, you would handle Android clients just like desktop clients, only with a different output format.
Related
I posted this question a few weeks ago, but perhaps it came off as vague and wasn't really well accepted. So I'm going to try and be more specific, since I am still looking for an answer.
I have an idea for an iphone app that I wanted to start working on. I'm a Web Programmer by trade, and was considering writing the application initially as a website. (intended for Desktop / Laptop users). Once I figured out all the ideas, I was then going to use that as a blueprint for the iphone app.
My question is: It would be great to have both versions running, and thus, sharing as much code as possible. Is there a practice, methodology, or set of principals for dealing with this sort of scenario? For Example: www.facebook.com and the Facebook iPhone app.
I'm thinking that the endpoints which the iPhone accesses to retrieve data, should be the same code that the Web Application uses to retrieve data. Or with different platforms running, is it common practice to maintain completely separate code bases?
To be clear, my iPhone App would be a native iPhone app.
thoughts?
you can create a webservice for that,you can use json or xml to create webservice response format.
you can use that webservice with any platform. by parsing json or xml you can get your data and display it according to your platform specific design.
I have a shop project written with Zend Framework 2 and now I want to write an app for this project. I'm new to this whole Android thing (I wrote a few test apps, but no big project like this). So at this moment I'm planning the "app-project" but i didn't find that much till yet.
I have to write the API in PHP and the complete Android app, so I just wanted to ask if someone can show me some good tutorials/sites etc to get more information for this (there are some big topics I'd like to know like security with the JSON communication etc).
If you're building your API in PHP assess first which framework you want to use. I've had success using Yii to build a quick REST JSON API. After getting to grips with Yii this article explains in detail the process of building a REST API: http://www.yiiframework.com/wiki/175/how-to-create-a-rest-api/
You have a few choices in terms of authentication and securing your API. Firstly make sure all data is sent over https otherwise your efforts to secure your API are wasted because anyone listening on your network can read requests/responses in plaintext. Look at using OAuth or a HMAC pattern similar to Amazon web services for authenticating requests. Here's a great article on the latter: http://www.thebuzzmedia.com/designing-a-secure-rest-api-without-oauth-authentication/
I want to use PHP (Symfony2) because building apps with it is quicker than building apps w node (IMO). I want the speed and scalability of node, however. My proposed solution is to use node to handle all of the app's data. I would then use Symfony2 as a client to node and pull any data I need from the node server's REST API. I could then connect to node directly with my iOS/android app and take advantage of its scalability. Is this a viable solution? How can this be improved?
What makes Symfony or any Rails inspired framework fast to develop is the scaffolding.
By using Node for the backend to handle the data management (API), you are loosing all of that, and keeping only the VC (View Controller) of Symfony's MVC. And you won't get any faster if you only keep those and add the mess of having 2 backends.
They are some Rails inpired frameworks for Node.js out there.
Railway is one of them.
If I understand you correctly you want to know.
a). If you can build a API server with nodejs. The obvious answer is yes.
b). If your PHP app can get data from the nodejs api server. Again yes you can do this.
c). If your mobile app can get data from the nodejs api server. 3rd time yes.
But understand that you now have to deal with two separate server-side technologies\langauages.
You will have to weight-up if this "quicker" or "more maintainable" then building both applications using the same stack.
I have an existing PHP/MySQL website that relies hugely on form POSTs for things like signing up, logging in, searching etc. I now need to create a native iPhone app for it. The business requires a native app for marketing reasons, I can't get away with a mobile optimized website.
I'm looking for suggestions from someone who has already done this - how did you rewire your website to POST/GET data from the iPhone app? I'm guessing I'll have to send/receive data as XML, which is then parsed by the server and client. Is there anything simpler or any framework that can make this easier?
Thanks!
If you don't have some sort of webservices or API to connect through for the website I would make that my first priority. While you can scrape HTML and send POST requests, it can get quite messy FAST. I've created iPhone apps which talk with webservices through SOAP requests, and have built an iPhone interface to a site, which wasn't pretty. It is very doable, but it is also very frustrating if anything changes on the webpage.
If you are looking for a decent library to help you get started with POSTing against forms check out the ASIHTTPRequest library at http://allseeing-i.com/ASIHTTPRequest/. If you look at the site there is a 'How to Use It' page with 'Sending Data with POST or PUT Requests'. Otherwise you could just use NSURLRequest and NSURLConnection and handle everything yourself.
It depends a lot on what you are presenting. You may be able to put a lot of your php heavy interfaces into web pages. The web pages and all related resources would be local to, and formatted for the iPhone. You can look at PhoneGap for examples of how to host local web pages and communicate with the host application.
I have been writing an eBook reader. About half of the user interface is done through local html files. In my case there is no network access, but WebKit is the easiest way to style text.
As long as your application does not look like a web page, it is fine if it is a web page. That may simplify big chunks of server interaction, especially things like login that only happen once or rarely.
Jonathan,
I would recommend taking a look at the Apple provided SeismicXML sample app. It uses the NSXMLParser to parse XML in a asynchronous fashion which will be huge for your app. It also shows how to use a NSURLConnection to make the request off of the web. You can use the NSURLConnection (which is also asynchronous) for POST/GET requests.
As mentioned in another answer, the ASIHTTPRequest library from allseeing-i.com is an excellent library but all of the features you want can be done using the built in Apple APIs if needed for your business requirements.
Hope this helps!
I am working on a social network project in PHP/MySQL. If you have ever seen or used the myspace or facebook iPhone app you will see what my question is all about. I am curious what most iphone apps do with the server for a social network type iphone app. I was tyhinking possibly it uses a REST server with jSON or XML output and possibly the iphone app will just read that? Or does most iphone apps do there own query to a database somehow? Sorry I really don't have any knowledge in that sort of programming so I could be way off on all this.
So basicly what would be the most efficient way for a iphone app to get data from a server?
In my opionion, the ASIHTTPRequest Library, a RESTful Webservice and the JSONTouch library are working great together.
To get you started (including a PHP/MySQL example) take a look at this great tutorial:
iPhone Coding Tutorial – Creating an Online Leaderboard For Your Games
A RESTful approach is almost certainly the cleanest and easiest. The iPhone API has great support for communicating via XML.
There are some fairly comprehensive examples in Apple's Developer Connection.
http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/XMLParsing/XMLParsing.html
You would use JSON or XML web services but you can use whatever HTTP mechanism you like.
Answering the second part of your question no the apps don't normally talk direct to the database but use web services instead.