Back-End database for image based TableView - php

I am some what a beginner in iOS development, and am beginning to move from the front-end dev to the back-end. I know using JSON with php and MySQL is probably the most common to use for loading table views from databases, but I am wondering if anyone has some insight in where and how to start this process for building a database to load image based user-generated content to TableViews (much like instagram).
I know this is not a programming specific question, just trying to get some direction on where to pin-point my efforts. Appreciate any and all input.

Okay so learning how to build a database(MySQL) . I found some links that can help you.
http://www.wikihow.com/Create-a-Database-in-MySQL
http://dev.mysql.com/doc/refman/5.1/en/database-use.html
It isn't advisable to store images in tables because you'll encounter problems when it comes to backing up. Save images in a folder on the server and store their references in the tables.
To Access this images from your app. You'll need to make a post request to your database through an API written in PHP. You can find a good tutorial on how to write a simple PHP API script on google.

I don't have enough reputation so I wasn't allowed to post more than 2 links. So my answer continues
From your app you hit your API with the necessary parameters you set when writing the PHP script with a POST request. You API should return you the url of the image you seek and you should be able to download the image in your app.
This is a tutorial on how to make a simple NSURL Connection
http://codewithchris.com/tutorial-how-to-use-ios-nsurlconnection-by-example/
Below is another link that might be of good help. Its a simple tutorial that builds a messaging app that hits an API and gets messages from a database. There is a lot of learn from there to fulfill your need.
http://www.ibm.com/developerworks/library/x-ioschat/

As an alternative to the traditional ways I find Parse very useful. Parse can manage your whole backend and they have a very powerful free basic plan.
If you focus on images dive here in, to decide wether Parse fits for you or not: https://parse.com/tutorials/saving-images

Related

Get data from a website to iPhone app

I have a couple of questions. I hope people can give me a good view because I am stuck at the moment.
It's a year since I started developing so please bear with me.
How can I get data from a website that I don't own to my application?
I have done some database parsing before but that's all from my own website. I see people use different library's (HPPL for example).
But what if the website requires users to login? And besides does that work on HTML only? What about if it's a PHP based site?
Should I get the external data directly on the iPhone when opening the app or should I use a middle-man approach (server between external website and app that handles the info)?
3) What is the best way to save login information so that a user doesn't have to fill in every time he opens the app?
I am a bit confused about all the stuff so maybe you can clear things up.
The question is extremely broad; so you will get pretty general answers.
Essentially, you are asking how to consume a web service. For that question, I'd recommend one of several tutorials online, like this one. There are others. That should give you a start.
You should understand the Cocoa URL loading system. The documentation is very complete. You can certainly use third-party libraries for this, such as AFNetworking; but I would recommend you understand the Apple -provided frameworks first.
But what If the website has a login ?
Depends on what sort of authentication we're talking about.
And besides does that work on HTML only ? What about if it's a php based site ?
No. Should be no different.
should I get the external data directly on the iPhone when opening the app or should I use a middle-man approach (server between external website and app that handles the info)
In general, a simple design should be favored over a more complex design so long as it meets your specifications. There's probably nothing the intermediate server can do that the iPhone cannot - but we don't really know your specs.
What is the best way to save login information so that a user don't have to fill in every time he opens the app I am a bit confused about all the stuff so maybe you can clear things up...
You will want to investigate the Keychain then. See this SO question for a bunch of tutorial references.

Need help to figure out how to do a remote API connect call on my site

I have some skills in PHP and now I'm planning to develop a connect function for remote login to my web side. I can't find any useful on Google.
Some idees on how to code a API connect button? Something similiar to Facebook connect, Twitter connect etc. BUT this should not rely on facebook api. I'm going to make my own stand alone api.
I know I need to use REST in backend, but I'm missing the knowledge to know how to send / recive the login data, and how to know when a user are online or not.
I also know that the user will need a key of some sort.
My plan was something so easy as this:
yourdomain.com/api?id=xx&key=xxx&what=
then what is should be the action with som parameters like:
if($what == login) {
handle the login part here
return the data
}
I can handle the php on the server side, but don't have a clue on how to handle the rest except the remote site must get the data in json or xml format and save in database.
Then when connect, it sends some data back to my site.
But HOW?? Here I'm stuck.
Also how to figure out when user are online on the other site or not, and how to get the image for a button. Like Facebook have a blue icon.
I guess it's a call back to my site for getting the image from there, right?
Greatfull for any answers on this one.
Its a pretty large topic you have there, you'll need to do some research as there are many many ways and technologies and security aspects related to this.
I'd suggest you go with a secure connection on a SOAP service based off Zend Soap Server and Zend Soap Client. But then again, if you don't want to use ZEND or SOAP, you'll have to look at other methods.
I wouldnt use REST because REST is used to manage data such as PUT/POST = UPDATE/INSERT, DELETE = DELETE, GET = SELECT so i don't really recon this would make sense.
My biggest point i have to make is, MAKE APIS, something simple, you don't want people to have to ask you for help or read documentation on how to access your authentication service. Go something simple, clean, portable and provide API to simplify your user's experience.
My 2 cents :P

Saving peoples progress on flash games onto a site

I know there are sites out there when you log on to their account they can play swf games or otherwise flash games on the site so whenever they go to another computer they can continue their progress without restarting just by logging onto their account.
I would like to know how they do this. So I can added it to my site. I honestly have no clue where to start to learn this. Any help leading me to the right direction. Or if you can give me some code. I would appreciate it more.
Well, you'd need to create a php/mysql based API for developers. Whatever functions you want them to be able to call in flash to save data, you'll need to code in PHP. You'll also probably have to code something to access the API, in the form of Actionscript code.
It's not something really easy that you could just "add to your site", probably the biggest thing you'd have to do is get developers to integrate it to their games. There's (unfortunately!) no magic self-implementing code which a flash developer can add to their game which has a standard serverside library, for saving data.
You'll probably want to take a look at this tutorial for the basics of how to go about implementing this.

Real time activity feed - code / platform implementation?

I am defining out specs for a live activity feed on my website. I have the backend of the data model done but the open area is the actual code development where my development team is lost on the best way to make the feeds work. Is this purely done by writing custom code or do we need to use existing frameworks to make the feeds work in real time? Some suggestions thrown to me were to use reverse AJAX for this. Some one mentioned having the client poll the server every x seconds but i dont like this because it is unwanted server traffic if there are no updates. I was also mentioned a push engine like light streamer to push from server to browser.
So in the end: What is the way to go? Is it code related, purely pushing SQL quires, using frameworks, using platforms, etc.
My platform is written in PHP codeignitor and DB is MySQL.
The activity stream will have lots of activities. There are 42 components on the social networking I am developing, each component has approx 30ish unique activities that can be streamed.
Check out http://www.stream-hub.com/
I have been using superfeedr.com with Rails and I can tell you it works really well. Here are a few facts about it:
Pros
Julien, the lead developer is very helpful when you encounter a problem.
Immediate push of new feed entries which support PubSubHubHub.
JSon response which is perfect for parsing whoever you'd like.
Retrieve API in case the update callback fails and you need to retrieve the latest entries for a given feed.
Cons
Documentation is not up to the standards I would like, so you'll likely end up searching the web to find obscure implementation details.
You can't control how often superfeedr fetches each feed, they user a secret algorithm to determine that.
The web interface allows you to manage your feeds but becomes difficult to use when you subscribe to a loot of them
Subscription verification mechanism works synchronous so you need to make sure the object URL is ready for the superfeedr callback to hit it (they do provide an async option which does not seem to work well).
Overall I would recommend superfeedr as a good solution for what you need.

Server setup for basic forum-style app on iPhone?

I'm not really a server-side person – I generally do iPhone apps, though I've hacked together a few Wordpress sites.
I'm curious as to what web technologies people would use for the back-end of an iPhone app whose front end presents as a basic forum. In other words, people can create new threads, and respond to them - with plain text only.
The forum would not exist as a website.. the only way to access it would be on the phone.
What technology would people recommend I use? Ruby-on-Rails with Amazon S3 storage? Could I even use existing forum software and pass and receive data to and from it? Perhaps even a forum Wordpress plug-in? Or is there a better way?
If you wanted to, you could use existing forum software and/or Wordpress to facilitate what you want, which would be easier than building your own forum from scratch. You could, with that existing framework, set up your own little API to communicate from the iPhone app to the server- for example, send a $_GET request to a PHP script on your server, which would return a list of forum topics. You could have similar PHP scripts that could do similiar functions, like adding a post or deleting topics.
That's pretty much how I've got it set up on an iPhone app I recently made- my server has a basic forum system, and I just wrote a couple of PHP scripts to return information from a MySQL server. However, if you'd particularly prefer to use Wordpress/Amazon S3/whatever else, then I could give more specific instructions relating to those services.
*EDIT*
Here's an example PHP script you could use (after you've created databases):
forumcategories.php
<?php
// insert database connecting logic here
$query = mysql_query("SELECT * from categories");
echo "<categories">;
while($row=mysql_fetch_array($query)){
echo "<category><id>" . $row['id'] . "</id><title>" . $row['title']; . "</title></category>;"
}
echo "</categories>";
?>
This is a really simple script- of course, you would need to add in code to connect to the database (which can be found easily online) and probably some error checking, but other than that, it will do the trick. What you would do in the iPhone app is send a request to http://yourserver/forumcategories.php and it would return XML listing all of the categories, which can easily be parsed with NSXMLParser and placed into a UITableView, for example.
Google App Engine is very good for what you describe. There are a lot of advantages to this approach: choice between Java and Python, access to the Google Accounts API, persistence/datastore APIs,... and you don't have to setup much to start working.
I also recommend that your server app returns responses formatted according to Apple's XML Property List format, instead of any other XML or JSON format. You can avoid NSXMLParser (or any other parser) altogether and save time to use on other important stuff.

Categories