Discussion Forums  >  Uncategorized

Replies: 5    Views: 414

mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
10/24/11 09:55 AM (14 years ago)

creating a custom usage map within ios app

I initially mentioned this in another post but wanted to start a new thread. As of now the report to cloud can send user information such as GPS coordinates back to the buzztouch server. that information is then used to populate the app's usage map. My apps are disconnected from the buzztouch control panel by keeping the config.txt file in the app itself and removing the report to cloud and data url sections in that file. Because of this I don't think my user map works. Is it possible to create a report to cloud url on my own website that would only collect user GPS data and not when the app was last updated? And if so, could I then have a custom google map showing, say, the lats 100 users?? That would be absolutely awesome! Thanks, Josh
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
10/24/11 10:38 AM (14 years ago)
Hi Josh, You can absolutely do this. If you look at the documentation for the Report to Cloud URL, it gives an example of sending the data to your own website and mySQL database (or whatever DB you choose to use), and even provides a sample php script to make it work. You could then extract this data from within your app (make a php call to your database) and generate the map you wanted. I believe you can do this while keeping the app offline, since the BT_Config.txt URLs and Report to Cloud URLs are mutually exclusive. Mark
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
10/25/11 02:44 PM (14 years ago)
OKay, I'm going to give this a shot. I host my files on bluehost.com. I created a mySql database called erresapp_map. I then made a table called ERres which has three columns: deviceID, devicelatitude and devicelongitude. Now, on the buzztouch website I see this as the php script: <?php //get the device information from the URL $deviceId = $_GET['deviceId']; $deviceLatitude = $_GET['deviceLatitude']; $deviceLongitude = $_GET['deviceLongitude']; //query to save device information in database $sql = INSERT INTO Stats_Table (deviceId, deviceLatitude, deviceLongitude) ; $sql .= VALUES (' . $deviceId . ', ' . $deviceLatitude . ', ' . $deviceLongitude . ') ; //execute query here.... //output the app's last modified date in JSON format for the app to consume and save. echo {\lastModifiedUTC\:\Sat, 04 Jun 2011 06:40:32 -0700\}; ?> This may be a stupid question, but is a php file just that script? do I need HTML tags or anything? Where in the script do I put the name of the database? Thanks!!! Josh
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
10/25/11 03:18 PM (14 years ago)
Hi Josh, You're on the right track! There is quite a bit to learn here to make this work, but you're absolutely going in the right direction. You can call a php script from a browser without any HTML inside, assuming that it doesn't return anything you want to show the person in the browser. The basic syntax for sending the data would be something like : http://bluehost.com/erres_script.php?deviceID=<something>&devicelatitde=<something>&devicelongitude=<something> Here's an example I have employed where I send the device lat and longitude to a database: This is Custom URL I have configured for my screen : <domain>/app-test.php?latitude=[deviceLatitude]&longitude=[deviceLongitude] This is the php script on the backend : <?php $latitude = $_GET['latitude']; $longitude = $_GET['longitude']; $db = mysql_connect(localhost, <userid>, <password>); mysql_select_db(<dbname>,$db); if ($submit) { $SubmitterEmail = $_POST[SubmitterEmail]; $latitude = $_POST[latitude]; $longitude = $_POST[longitude]; $Status = $_POST[Status]; $Description = $_POST[Description]; $sql = INSERT INTO theguide (SubmitterEmail, latitude, longitude, Description, Status) VALUES ('$SubmitterEmail','$latitude','$longitude','$Description','$Status'); $result = mysql_query($sql); header(location:http://www.google.com/); }else{ $error = $resp->error; } ?> This sends information from a form, including the device lat/long, into my DB.
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
10/25/11 03:54 PM (14 years ago)
There is quite a bit to this like I mention. Here is a good link that shows how to take information from an HTML form and put it into a mySQL database using php. You can extend pretty much all of what you learn here to your example : http://www.tizag.com/phpT/examples/formex.php
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
10/25/11 04:00 PM (14 years ago)
Thinking about this for a few more seconds, I would concentrate on getting the info into the database in the first place. Then you could work on extracting it for a JSON file. It appears that the Report to Cloud URL is contacted when the app launches. So, you would use your link to a script on your server that would be formatted like I mentioned above : http://bluehost.com/script.php?&deviceId=[deviceId]&deviceLatitude=[deviceLatitude]&deviceLongitude=[deviceLongitude] That will send the device Id, Latitude and Longitude to your script. In the script you receive the inputs using the $_GET variable. Then open your database, open the table, and write the values. At that point, you should have them in your DB and can check using something like phpMyAdmin or another tool to check DB data. I'd work on getting this part operational first. Extracting the info is pretty easy. Mark
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.