Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 16    Views: 140

Majed
Lost but trying
Profile
Posts: 1
Reg: Feb 19, 2014
Yanbu
10
02/19/14 04:50 AM (11 years ago)

Why there is no plugin for Database connectivity?

Hi all I've just discovered Buzztouch. The overall looks good, but I'm looking for anything that would allow me to collect data from mobile users, send them to a database, retrieve them, etc. Why there is no interest in Databases here? Thanks
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/19/14 04:57 AM (11 years ago)
Welcome to Buzztouch! Lots of interest in DB Connectivity, but the kind of form you want is different than the kind of form I want. Most all of it, for the most part, is custom built. A lot of people use this tutorial: https://www.buzztouch.com/files/howtos/Posting_Current_Location_to_a_Database_v1.0.pdf to get started. But if you have more questions, stop on by! :) Cheers! -- Smug
 
bigPaul
Lost but trying
Profile
Posts: 103
Reg: Mar 08, 2013
Darwin
4,530
like
02/19/14 07:25 AM (11 years ago)
@Majed, as Smug suggests, everyones form requirements vary so its bit hard to create a generic plugin. Most of us use the process outlined in the GoNorthWest tutorial by designing our forms in html and using the respective html plugins to process them. However, a plugin I would like to see is one that similarly uses our own html designed forms to collect data but store it in the device memory so that at a latter stage it can be uploaded in bulk to host database. My reason being is that I spend a lot of time in remote areas with no phone/wifi coverage. Currently I use other excel/database apps to do this but it would be good to make my own dedicated app! Regards, Paul
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
02/19/14 07:28 AM (11 years ago)
There is a web form plugin I have in the market that would allow you to do this. It requires you to have a php script on your server (although a sample script is provided). Also it's iOS only. But would be a lot cheaper than paying to have a custom plugin built.
 
epicweb
Aspiring developer
Profile
Posts: 159
Reg: Aug 30, 2012
Glen Carbon
4,990
like
02/19/14 08:15 AM (11 years ago)
I would love to be able to add information into the buzztouch database instead of using a different database. All sorts of security reasons why buzztouch.com users cant do it but self hosted users could do this without problems because you can setup your own php files. The issue then becomes accessing that data inside the buzztouch control panel. I know I could get it work but haven't had the time to do so.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
02/19/14 09:03 AM (11 years ago)
@epicweb - yep, this is definitely possible. I've made several custom plugins for people that do this exact thing. One was a photo uploader - certain (registered, paying) users could upload photos to the server - the server would save the photos and simultaneously create a child item for a menu screen containing a link to the photo so everyone with the app could see the photos. Another was a voting plugin where users could vote on something and the app would send the vote to the server where it would be saved in the self-hosted database so all users could see the total of all votes. Takes a bit of work, but if you know the basics of php and mysql and understand how the JSON is working in a Buzztouch app, it's not that difficult.
 
epicweb
Aspiring developer
Profile
Posts: 159
Reg: Aug 30, 2012
Glen Carbon
4,990
like
02/19/14 09:06 AM (11 years ago)
@chris1 would be you willing to share the steps you did to get it to work or even those plugins? I understand if its custom work for a client and you cant share. Just trying to save a bunch of hours in development :) I would be willing to purchase the code.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
02/19/14 10:07 AM (11 years ago)
Here's the gist. The plugin code uses a button action to send data to the server. The code for sending data differs depending on whether your attaching a file or simply sending text. (It's a bit more complicated for attaching files). Once the data is sent, it will work just like an HTML web form - you need a PHP script to read the data and do something with it. I'll paste code for sending data from the app in the next two posts.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
02/19/14 10:09 AM (11 years ago)
This can be used to send text data. It takes two variables: (NSString*)encodedString -- this is the data to send, should be in the format: @"name=Chris&[email protected]&age=34"; (NSString*)theURL -- this is the location of the PHP script to send the data to: @"http://yourserver.com/yourscript.php"; -------------------------- Here's the method to paste into your code: -(NSString*) postEncodedString:(NSString *)encodedString toURL:(NSString *)theURL{ NSURL *phpScriptURL = [NSURL URLWithString:theURL]; NSData *postData = [encodedString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]]; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:phpScriptURL]; [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody:postData]; NSError *error; NSURLResponse *response; NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding]; NSLog(@"%@", data); return data; // // UIAlertView *showResult = [[UIAlertView alloc]initWithTitle:@"" message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; // // //check results of post // if (!data) { // showResult.title = @"Uh oh!"; // showResult.message = @"Something went wrong. Please try again later."; // [showResult show]; // } // else { // [BT_debugger showIt:self theMessage:data]; // showResult.title = @"Thanks!"; // showResult.message = @"Form successfully sent"; // [showResult show]; // } // // [showResult release]; }
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
02/19/14 10:12 AM (11 years ago)
This method sends an image and some text data to a php script. It takes 4 arguments: (UIImage*)theImage -- the UIImage to send. (NSString*)fileName -- the name of the image to use (NSDictionary*)theDictionary -- the string data in dictionary format, where keys are keys and values are objects (NSString*)theURL -- the location of your php script --------------------------------------------- Here's the method to paste into your code: - (void) uploadImage: (UIImage *)theImage withFileName:(NSString *)fileName withStringDictionary:(NSDictionary *)theDictionary toURL:(NSString *)theURL { [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"uploading image and caption to:%@", theURL]]; NSMutableData *body = [NSMutableData data]; NSString *boundary = @"---------------------------14737809831466499882746641449"; NSData *imgData = UIImageJPEGRepresentation(theImage, 1); //NSData *imgData = UIImagePNGRepresentation(imageBox.image); [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"image size:%i", imgData.length]]; NSURL *url = [NSURL URLWithString:theURL]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary]; [request addValue:contentType forHTTPHeaderField: @"Content-Type"]; // file [BT_debugger showIt:self theMessage:@"uploading file:"]; [BT_debugger showIt:self theMessage:fileName]; [body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithFormat:@"Content-Disposition: attachment; name=\"File\"; filename=\"%@\" \r\n", fileName] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[NSData dataWithData:imgData]]; [body appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]]; //string data NSArray *theKeys = [theDictionary allKeys]; for (int i=0; i<theDictionary.count; i++) { NSString *keyName = [theKeys objectAtIndex:i]; NSString *keyValue = [theDictionary objectForKey:keyName]; [body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",keyName] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[keyValue dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]]; } // close form [body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; // set request body [request setHTTPBody:body]; NSError *error; NSURLResponse *response; NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding]; [BT_debugger showIt:self theMessage:data]; if ([data length]>0) { if ([data isEqualToString:@"success"]) [self showAlert:@"Thank you" theMessage:@"Image successfully uploaded" alertTag:0]; else [self showAlert:@"Error" theMessage:@"Image not uploaded" alertTag:0]; } else { [self showAlert:@"Error" theMessage:@"Something went wrong - please try again later" alertTag:0]; } }
 
epicweb
Aspiring developer
Profile
Posts: 159
Reg: Aug 30, 2012
Glen Carbon
4,990
like
02/19/14 10:28 AM (11 years ago)
very nice chris1
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
02/19/14 09:17 PM (11 years ago)
Nice share, Chris! Thanks -- Niraj
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
02/20/14 07:55 AM (11 years ago)
Great stuff Chris. Thanks. Codeboxed! Have you played with NSIncrementalStore at all?
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
02/20/14 08:52 AM (11 years ago)
I keep forgetting about Codebox -- Yahoo mail is my Codebox. Most times, my snippets are saved via iPhone or iPad by sending an email of the code to myself. Then I file it into the burgeoning BuzzTouch or BTfixes folder. Is there a way to get a new snippet into the Codebox repository via an iOS device?
 
DouceTech
Apple Fan
Profile
Posts: 6
Reg: Jan 25, 2014
New Orleans
2,310
like
02/20/14 01:42 PM (11 years ago)
Hi all, Im a new member that joined to be able to build an app that is on this topic, so I thought it would be a good place for me to jump in. Im basically looking to create an incident report or police report that can be used on an iPad. I would love some tips/pointers to help me get started. I very green when it comes to mobile app dev. , I have built the report in an html formate using dreamweaver but it E-mails me the file then I have a script that moves the new data to a data base but its not-automated like I want it to be. I have been googling all the data on the subject and I have found lots almost to mush and now more confused then before. So Im looking for a little push in the right direction to help me get started. Thanks D.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/20/14 01:54 PM (11 years ago)
The easiest and fastest way would be to use a custom URL pointing to a web form that can be filled out. Perhaps not the *best* solution, but easy, fast, simple. Longer and more drawn out would be to emulate that form in Xcode/Android. David Book did a video on 'how to build a plugin' that would be a good start in seeing how to 'connect the dots'. https://www.youtube.com/watch?v=OJrMVTn8z0s When you get questions, the forum is chock full of folks who have done it, want to show you how, and other folks who also want to do it, and share your keen interest. Don't be shy! When you have questions, ask! Cheers! -- Smug
 
DouceTech
Apple Fan
Profile
Posts: 6
Reg: Jan 25, 2014
New Orleans
2,310
like
02/20/14 03:23 PM (11 years ago)
Thanks for the info. Maybe I should repost my question in the general section then and press on from there. Thanks again for the link I'll check it out.
 

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.