i apologize for any confusion. Yeah, it must be a string. the controller I'm using was part of a tutorial that didn't really explain what was going on. It's something that is returned from linkedin (object? string?). bellow is the controller that gets the xml.
Code:
class profileController {
def apiUrl = "http://api.linkedin.com/v1/people/~:(" +
"id," +
"first-name," +
"last-name" +
")"
def oauthService
def index = {
if (session.oauthToken == null) {
redirect(uri:"/")
}
if (params?.apiUrl) apiUrl = params.apiUrl
def linkedinResponse = oauthService.accessResource(
apiUrl, 'linkedin', [key:session.oauthToken.key, secret:session.oauthToken.secret], 'GET')
processData(linkedinResponse) //this is where i send the item to my code to be processed.
render(view: 'index', model: [profileXML: linkedinResponse, apiUrl: apiUrl])
}
def change = {
if (params?.apiUrl) {
println("Setting api url to " + params.apiUrl)
apiUrl = params.apiUrl
}
redirect(action:index,params:params)
}
edit:
i think it may be due to first-name having a hyphen. when i use three double quotes around first-name, i dont get an error. below is my new code:
Code:
XmlParser parser = new XmlParser()
def myPerson = parser.parseText (linkedinResponse) //changed response to linkedinResponse
myPerson."""first-name""".each {
print myPerson."""first-name""".value
}
this does not produce an error but only prints out []