Updating App with Web Information - cocoa

Hey everyone, I am sorry if this question has already been asked/answered
But I have a Cocoa program that has different arrays of models. Each model hold just Strings and one Image. Archiving and Loading works great.
Each model represents a web account, that is, it holds the username and password, and some other information related to the website. Moving forward I would like to be able to update information in each model by accessing the information from the website. For example updating a balance ($). I am wondering if there is a way to do that programatically that is:
Automatically log into web account using the entered username, pass, and website url
Update the balance based on the information following log in.
Thanks for the help in advance!
Tamara

There is no single approach to log into any arbitrary website. You will need to know what the API for the given website is. If the website provides a web service to query things like balance, then you would connect using that web service (REST-based if at all possible; SOAP is more of a pain in Cocoa), and update your model based on the results. If the website provides no web service, then you would have to scrape through the HTML responses looking for what you want, and this is generally very complex and fragile. There is no general answer to this question; you'd have to know what form the website is in.
On another note, make sure that you are not storing user passwords in unencrypted files. User passwords on Mac should always be stored in Keychain. There are many posts on SO about how to best use Keychain.

Rob, isn't it possible to just look through the login page's html source and see what are the names of the fields for user and pass, and then just send a POST request to that page from code ?

Related

Reconciling browser-side and server-side authentication

apologies if this has been asked but I'm trying to figure out this kind of stuff for the first time -
I'm developing an app where I want to divide the authenticated content from the web-facing side, completely; therefore I am not using a simple backbone.js-style "keep all views in one file" (unless I'm wrong about this, please illuminate!) but actually divided server files (using PHP).
Current flow: the user logs in client-side (using the Parse.com Todo app as an example) and, if successful, I store cookie (via POST/AJAX) with user email and the returned sessionToken on client side. I then thought that when user next visits site, the server can read cookie and shuffle the user to the private/locked portion of site, which, again, is a different set of PHP files.
Here I get lost -- how do I then tell Parse.com that the user is logged in, if I don't have her username/password (only email), and start grabbing data from the classes? Is there a way to do this that I'm not recognizing? I guess I can load different .JS files, read if a session exists, and JS-redirect to a different url, but that seems to me to be a weird way of going about it.
Is there a general philosophy/methodology to my questions that I should read up on, along concrete advice dealing with Parse.com questions?
I believe the Parse User session management functions should be good for you.
Check out https://parse.com/docs/cloud_code_guide#webapp-users
There is an example at the bottom of their announcement blog post here: http://blog.parse.com/2013/09/04/new-cloud-modules-for-images-and-users/
It gives you user session management with minimal effort.

sso with netsuite integration in spring using cas

I want to implement Single signon between Spring application and Netsuite using cas. Seached many things on net but nothing was fruitful. kindly help me on this with some links or documents.
Thanks in advance.
I just completed two SSO's in NetSuite for our firm. (You will find this under Setup>Integration>SSO) We ended up having NetSuite send a specifically crafted URL to our internal PHP intranet. The web app' there receives the incoming URL and does stuff on it, and the user gets what they need.
Forgive me for not knowing anything about Spring, but if you can run your web app' to receive an incoming URL (post), then you will create a new SSO object inside of your ERP instance, and pass the values that you need to pass to your web app' from there. Those can be built-in values that come right out the system (ie: "{entityid}") or these can be values that you create with a script, pass them to the SSO, then the SSO passes those to your web app'. You can "place" an SSO "object" on to a "custom Tab" on your "custom Form". Or you can create an entirely new Form. Or you can place your SSO in some other location. I chose to place ours on a custom Tab, as that was effective for our use case.
The only other two places you can "place" your SSO is on to a "Portlet" (say, like a custom panel on your Dashboard or similar) or a "SuiteLet" (which I havent done yet but am working on right now).
If you have any "bundles" installed in your instance, some of them have SSO inside of them, and some of them are "protected" and some of them are not, and the unprotected ones can be downloaded as JavaScript to your machine for examination, consideration, & emulation.
The help in SuiteAnswers is decent but doesnt give many working examples for your to adapt. The PHP Tool Kit has a working sample of an SSO inside of it & I highly recommend getting that, unzipping it, and reading all of those files, even if it has no table of contents, you can easily follow all the includes and references amongst those files.
If you have a specific follow-up question about something in there, please post, and while I'm an intermediate at it, I'll give it the ole college try to answer. And if you need anything past that, ping me.
Cheers.

store data for bookmarklet

I am making a bookmarklet, which calls a Google App Engine app. The GAE app uses login information, which I want to store in bookmarklet, so when user first clicks bookmarklet,it asks for login info, but from next time onwards it automatically supplies it.
The difficulty of a bookmarklet directly storing data is that it can only store data in cookie or in localStore, both of which "belong" to whatever page it is currently on. That means it won't work again the next time you use it on a different page, and it also means the page you are on can access the data, which is generally very bad for security.
There are two basic ways your situation is generally handled. The two main ways are:
1.) The application used keeps the user logged in with a cookie. The login information is not stored in the cookie; only a session ID is. This is like when you return to many popular websites, you don't have to log in again. Very often these types of bookmarklets open a small popup for the user which contains a page from the app. If the user is not logged in, the app prompts the user to login first. The bookmarklet in fact knows nothing about being signed in or not.
2.) Each bookmarklet is custom created for each person. So my bookmarklet would be different than yours. The difference is simply that mine will contain my login info in the code, and yours will contain your login information in the code. In fact we would each have to login to the app first before we can get our own personalized bookmarklet.
Generally, option 1 is better and easier and more secure.
If I understand it correctly,this Might help you. http://ajaxian.com/archives/whats-in-a-windowname
It allows for storing data in windowname in JS. Allowing for access of up-to 2 MB of data (A lot more than cookies can hold) and I believe can be used across tabs...

Windows Phone 7 UserExtenedProperties opinion…

I was thinking of a way to some how connect my phone user base to my site user base. Right now if an item gets added to the site via the phone the userId is generic and the site displays it as SmartPhoneUser. I was thinking it might be cool to display the unique phone id by using the UserExtenedProperties, however, after reading Nick Harris's blog about it I'm thinking it may not be a good idea as I don't want users to think I'm up to anything nefarious.
So I'm wondering if there are any suggestions out there on how to accomplish this task. Right now my site uses the JanRain module that allows multiple logins from other sites (Facebook, Yahoo, Google etc.). I'm letting users log in to their own accounts and using the information from those sites to populate my user table. I'm not sure if WP7 has something similar I can use.
Any thoughts on how I can accomplish what I want to do without using the ExtendedProperties?
We can accomplish something similar by creating a unique guid/DateTimeStamp KEY the first time the app launches and stored it in Isolated storage.
Reusing the same KEY by reading it from Isolated Storage should work.
[N.B. : Anybody with other ideas please do suggest/comment/contribute. Tx.]

Getting a facebook profile picture from an email address

I'm trying to get a user's facebook profile picture based on their email address. Effectively, I want to offer my users the option between using Gravatar for their image, or Facebook. However, the only way I know of to get a user's facebook image is via:
http://graph.facebook.com/[FBOOK USERNAME]/picture?type=large
Since the usernames may vary between facebook and my site, I would like to do this via email address rather than username. How do I query for someone's facebook profile picture via email address?
I see this question has a couple of years already but the same search approach can be taken using the Graph API:
GET https://graph.facebook.com/search?q={EMAIL}&type=user
You can try this on the Graph API Explorer. You don't get the profile picture directly but you get the user id which you can easily use to get the public profile picture.
https://graph.facebook.com/{UID}/picture
There doesn't seem to be an official way to do what you are asking. It seems like facebook has made this closed on purpose, probably something to do with privacy. Its actually really easy to do this in a few screen-scraping steps though:
Visit http://www.facebook.com/#!/search.php?q=#{USERS_EMAIL_ADDRESS}&type=all&init=srp
If page returns "No results found for your query.", then they don't have a profile.
Otherwise, the page will contain a thumbnail of the user for that email address. (something like http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs227.ash2/48219_72120057_3223_q.jpg)
I could write a sinatra app to do this in about 5 minutes, if anyone would like me to.
But I think gravatar and facebook should just be friends.
What you're asking to do is part of why Facebook Connect exists.
Using their not-too-cleverly-named XFBML you can request the image directly:
<fb:profile-pic uid="1256100362" facebook-logo="true" size="thumb"> </fb:profile-pic>
But you have to implement logins with FB Connect first...

Resources