I need to upload Contact's information to the web server. I know that it can be done using HTTP PUT approach.
Also API from Address Book Programming guide, even some wrappers (such as RHAddressBook), allow us to generate NSData from Person's contact information.
I detected by WireShark how it is done on one of the servers.
For instance the part of URI for creating (uploading) vCard is this:
.../default/17b0dff5-5145-4515-85c0-5eb56f225f12.vcf
How to generate that tag (17b0dff5-5145-4515-85c0-5eb56f225f12)?
How it is calculated from vCard's data?
Dont know which server you are going to interact with but, in general, the last segment of the URI just need to be unique in the addressbook collection on the server. That is why many clients use some form of UUID.
In other words, the URI is not calculated from the vCard.
Related
I'm building a Python Flask web application that performs an analysis based on the inputs a user enters. I want to allow the user to send this analysis to their Facebook friends as a link; therefore, I need the analysis page to have a unique URL for every instance.
My approach up to this point has been to build the analysis page URL like so:
website.com/results/<Facebook ID>/<time in seconds since the epoch>
I'm using time.time() for the last parameter and the analysis data (paired with the FB ID and time) is stored in a database. An example URL might look something like this:
website.com/results/1619598720181063/1508036889
Does this approach seem feasible, are there best practices for generating a persistent unique URL, or is there a much better approach I'm overlooking?
Note I'm using Facebook's Send Dialog to share the link.
You might consider letting the database handle it for you by using an auto-generated unique key for the data. Key are guaranteed unique and your URI could be even simpler: results/123
I want to build a smart search agent which would use Watson conversation to process the request and give response but will use my own database say SQL server to search the desired output.
In Short Instead of writing intents and dialogues manually or importing from a csv file, I want to write my won code in .net in such a way that all the request and responses are influenced by my own data stored in my database. I only intent to use watson's processing and interpreting capability. But the processing must happen on my data.
E.g If the user searches for a word say "Dog", the Watson conversation service must search in my database and give relevant answers to the user based on the search.
Take a look at the solution architecture in the Watson Conversation documentation. Your database would be one of the depicted backend systems. Your application would be, as you mentioned, written in .NET and would use WCS to process the user input. It would return a response with all the associated metadata. Instead of having complete answers configured in a dialog, you would use something I have described as "replaced markers" in my collection of examples. Those markers are kind of hints to your application of which database query or which action to perform.
Note that WCS requires some intents and entities to work on. If you want to rely just on the detected intents and entities, you could work with one or two generic dialog nodes. As another technique you could use data from your database to generate intents and entities as an initial setup. In my "Mutating EgoBot" I use the Watson Conversation API to add intents and entities on the fly.
I believe you should use the standard trick:
instead of defining resposnses in the node of your diaglog, define an action on the output object of the node and let your applicatation take care of providing response (see https://console.bluemix.net/docs/services/conversation/develop-app.html#building-a-client-application)
I'm supposed to make an old sqlite database editable trough a Sketchup Plugin in its WebDialog. Sketchups Ruby is not able to install the sqlite3 gem and since I already need to display the table in a WebDialog, I opted for a micro service with the help of Nancy. The existing Plugin already uses the dhtmlxSuite and its Grid Component is exactly what I need. They even offer a Connector that can send requests based on the actions of the user in the grid.
They also offer a connector for the server side, but that too does not work with sqlite. I already managed to connect to my database, used Dapper to bin the result of an SQL query to an object and return that data with a manually crafted JSON object. Very hacky, but it populates the data successful.
Now the client-Connector sends data manipulated by the user (delete and insert is forbidden) back with an url encoded POST request that looks quite weird:
4_gr_id=4&4_c0=0701.041&4_c1=Diagonale%20f%3Fr%202.07%20X%201.50%20m&4_c2=AR&4_c3=8.3&4_c4=380&4_c5=38.53&4_c6=0&4_c7=0&4_!nativeeditor_status=updated&ids=4
I'm not sure exactly why the hell they would use the row index inside the key for the key-value pairs, but this just makes my life that much harder. The only thing that comes to my mind is extracting the data I'm interested in with a regex, but that sounds even worse than what I did before.
Any suggestions for me how I could map that POST request to something usable?
I have an application that has different data sets depending on which company the user has currently selected (dropdown box on sidebar currently used to set a session variable).
My client has expressed a desire to have the ability to work on multiple different data sets from a single browser simultaneously. Hence, sessions no longer cut it.
Googling seems to imply get or post data along with every request is the way, which was my first guess. Is there a better/easier/rails way to achieve this?
You have a few options here, but as you point out, the session system won't work for you since it is global across all instances of the same browser.
The standard approach is to add something to the URL that identifies the context in which to execute. This could be as simple as a prefix like /companyx/users instead of /users where you're fetching the company slug and using that as a scope. Generally you do this by having a controller base class that does this work for you, then inherit from that for all other controllers that will be affected the same way.
Another approach is to move the company identifying component from the URL to the host name. This is common amongst software-as-a-service providers because it makes sharding your application much easier. Instead of myapp.com/companyx/users you'd have companyx.myapp.com/users. This has the advantage of preserving the existing URL structure, and when you have large amounts of data, you can partition your app by customer into different databases without a lot of headache.
The answer you found with tagging all the URLs using a GET token or a POST field is not going to work very well. For one, it's messy, and secondly, a site with every link being a POST is very annoying to work with as it makes navigating with the back-button or forcing a reload troublesome. The reason it has seen use is because out of the box PHP and ASP do not have support routes, so people have had to make do.
You can create a temporary database table, or use a key-value database and store all data you need in it. The uniq key can be used as a window id. Furthermore, you have to add this window id to each link. So you can receive the corresponding data for each browser tab out of the database and store it in the session, object,...
If you have an object, lets say #data, you can store it in the database using Marshal.dump and get it back with Marshal.load.
I want to create a jokes application where jokes can be voted up and down and have ratings.
There is also different categories for the jokes.
My question is how should I store the jokes database?
The jokes database will be growing as application is updated. Do I want to store it on the phone or let the users grab the joke off a database in the web?
If the first option, what is the maximum capacity of text can I store on the iOS app? (In this case, I assume that jokes database will be updated as I update the app)
If the second option, how is this done? I can think of a couple of options, but they aren't really good.
1. store the database on a webpage and just grab it from there (but users cant vote up and down on the jokes)
2. create a mobile website that has all the jokes implemented like a real website, and use webview to show the jokes page to the user. (will probably need a log in system so users cant abuse the votes)
In these two cases, it is unsafe, because someone can just find out where my jokes are hosted by doing a google search and take all my content.
What do you recommend?
The most scalable solution is to build your own backend and fetch data from it on the phone. Application updates should be used for deploying code updates, not content updates. If you want a growing database of jokes to be available to the user, you're going to need a database stored somewhere on the web.
This approach requires you to set up your own webserver with a jokes database (using something like SQL or Postgres). You can use PHP, Ruby on Rails, Django, or other such server-side technologies to process incoming requests and fetch data from the database. The server would then vend this data back to the phone in a network-friendly format like JSON.
On the iPhone side, you can use NSURLRequest and NSURLRequestDelegate to make an asynchronous request to the server. For example, if you wanted to fetch all the jokes from the backend, you might make a GET request to http://www.yoursite.com/jokes. The backend will receive the request, use SQL queries to fetch the jokes, format the data as JSON, and send it back over the network to the phone. The phone can then parse the JSON (there a numerous JSON libraries for Cocoa Touch development) and update the display. To allow users to vote on jokes, you can similarly make POST requests to the backend, which will modify the data in the database.
Here's a simple example of how to work with JSON on the iPhone side: http://mobile.tutsplus.com/tutorials/iphone/iphone-json-twitter-api/