从 iPhone 发送数据到网站
我正在创建一个 iPhone 游戏,我希望用户在第一次启动应用程序时获得唯一的数字代码,这样当该用户的朋友打开它时,他/她可以输入该代码并且两个用户都可以获得奖励。我还没有遇到任何与此相关的问题,但是我想要做的是让应用程序注册提供给每个用户的代码并将其保存到网站某种程度的。这样,当其他用户输入代码时,它将从该网站加载数据并检查其是否已注册。 我如何设法将数据保存到网站上?以及我可以使用哪个免费网站来实现此目的,而正文页面上没有字符限制?
-提前致谢
I'm creating an iPhone Game where I want the user to get a unique numeric code when they first launch the app, that way when a friend of that user opens it, he/she can input that code and both users can get rewarded. I haven't encountered any issues regarding that, however what I want to do is make it to where the app registers the code given to every user and saves it to a website of some sort. That way when the other user enters the code, it will load the data from that website and check if it's registered. How would I manage to save the data onto a website? and also What free website could I use for this without having a character limit on the body page?
-Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的想法是正确的,因为您需要将数据保存在网上的某个地方,但您并没有真正按照您所描述的方式“将数据保存到网站上”。 “免费网站”服务通常服务于完全不同的目的 - 提供公共 html 页面。当然,它们可以采用 CMS 的形式(例如 wordpress.com 或 tumblr 帐户),但将其用作存储应用程序数据的接口并不是它们通常设计的目的。
对于这样的事情,如果您有一个需要安全访问自定义字符串的公共 iPhone 应用程序,您确实希望控制自己的 Web 服务器(不同于域名,顺便说一句),并与该服务器上的数据库进行交互。这是有代价的,并且涉及的代码比您在这里找到的人为您编写的代码要多。很抱歉这么说,但是嘿,如果有人想证明我错了,我很乐意看到它。
因为您需要存储和保存所有内容。检索是随机字符串(基本上是推荐代码......如果我理解正确的话),您的数据库需求非常简单。如果您不熟悉 PHP / MySQL 之类的东西,并且不想学习,那么可能值得向一些服务器端开发人员寻求帮助。除非事情比您描述的要多,否则您可能可以以相对便宜的价格找到人来帮助您。
祝你好运 - 很抱歉没有更简单的答案给你。
Your thinking is correct, in that you need to save your data somewhere online, but you don't really "save data onto a website" in the way that you're describing. "Free Website" services usually serve a different purpose entirely - that of serving up public html pages. Sure, they can take the form of a CMS (like wordpress.com or tumblr accounts), but using that as an interface for storing your application's data is not something they're typically designed to do.
For something like this, where you have a public iPhone app that requires secure access to custom strings, you really want to have control over your own web server (different than a domain name, btw), and interface with a database on that server. This will come at a cost, and will involve more code than you're likely to find someone to write for you on here. Sorry to say it, but hey if someone wants to prove me wrong I'd love to see it.
Because all you need to store & retrieve are random strings (basically referral codes... if I'm understanding correctly), your database needs are pretty simple. If you're not familiar with things like PHP / MySQL, and you don't want to learn, it might be worth reaching out to some server-side developers for help. Unless there's more to it than you describe, you can probably find someone to help you for relatively cheap.
Good luck - and I'm sorry there isn't a simpler answer for ya.
您可以使用 < 发送数据代码>NSURLConnection。只需创建一个
NSMutableURLRequest
并使用“POST”作为 HTTP 方法调用其-setHTTPMethod:
方法。然后,适当设置其正文和标头字段,就可以使用NSURLConnection
发送数据。You can send data using
NSURLConnection
. Just create anNSMutableURLRequest
and call its-setHTTPMethod:
method with “POST” as the HTTP method. Then, set its body and header fields appropriately, and you can useNSURLConnection
to send the data.