Solved

Return JSON from a CFC

Posted on 2011-03-01
5
493 Views
Last Modified: 2012-05-11
I want to return login credentials in JSON format from a CFC. I am working on this, but don't think its right.

<cfcomponent name="loginCFC" displayname="loginCFC" output="false" hint="test login cfc for mobile app">
<cffunction name="getUser" access="remote" returnType="any" returnformat="JSON" output="false" hint="returns user info">
      <cfargument name="username" type="string" default="">
      <cfargument name="password" type="string" default="">

      <cfset var qGetUser = "">

      <cfquery name="qGetUser" datasource="#application.datasource#">
            select user_id, user_id_code, fname, lname, email
            from users
            where lower(email) = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.username#">
            and lower(password) = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.password#">
      </cfquery>

      <cfreturn qGetUser />
</cffunction>
0
Comment
Question by:theideabulb
  • 3
  • 2
5 Comments
 
LVL 19

Expert Comment

by:Jones911
Comment Utility
What exactly do you want returned?
0
 

Author Comment

by:theideabulb
Comment Utility
i want to return all the data that is in my query.
0
 
LVL 19

Accepted Solution

by:
Jones911 earned 500 total points
Comment Utility
So ig you hit that cfc like http://url/cfc/loginCFC.cfc?method=getUser&username=a&password=b what do u get?
0
 
LVL 19

Expert Comment

by:Jones911
Comment Utility
Because it should work
0
 

Author Closing Comment

by:theideabulb
Comment Utility
HAHA! Your right it does work, i didn't try accessing it that way. I tried outputting it and dumping it.  Thanks.. Easy points for you :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now