PDA

View Full Version : Parsing after data retrieved from Yahoo,GMail,etc?


March 20th, 2006, 12:48 PM
When I import names from Yahoo Mail, the data can be

"emailaddress" <emailaddress>

for a user for whom no first name / last name is defined. That's fine. Or,

"first last" <emailaddress>

Is the first, last order from Plaxo, or from Yahoo? In other words, can I depend on the first name always being first, last name being last, if they are available?

Also, I created a name in Yahoo with commas in both the first name and the last name, and the commas were stripped out. I'm fine with that, but would like to know if Yahoo is stripping it before it gets to the Plaxo Widget, or if the Widget is stripping the commas?

(In other words, can I assume that there will never be a comma inside the double-quotes for the name portion?)

What about double-quotes and angle brackets in names, etc.?

Where I'm going with this is I want to know if I can do a simple "split" on the comma to get an array of all of the individual addresses, or if I would have to write a smarter parser.

John

March 20th, 2006, 08:22 PM
Hello John,

In general, you would need a smarter parser. Or, if you are feeling adventurous, you can register a JavaScript function that the widget will call with the names and e-mails split out (into arrays) so you can use that data without having to parse what's in the text field.

The secret sauce is to add the following code to the page where you host the widget button:

<script type="text/javascript"><!--
function onABCommComplete(data) {
// OPTIONAL: do something here when the new data gets populated in the text area
// data is an array of selected name/email arrays, i.e. [[name1, email1], [name2, email2], ...]
}
//--></script>

Then when the data comes back, it will also call this function, and the names and emails will be in the data array.

The only issue is that currently, you still ALSO have to pass a text area to the widget to pre-fill. But you can make it a hidden text area (with CSS) and then you should be able to just use the widget to call back to that JavaScript code and do some arbitrary AJAX/DHTML to process the selected contacts.

Over time, we may provide more robust facilities like this, but it's all we have for now.

Kathy