<cfcomponent>
<cffunction name="token" access="private">
<cfhttp url="https://api.twitter.com/oauth2/token" method="post" throwonerror="yes" result="output" redirect="true">
<cfhttpparam type="header" name="Authorization" value="Basic #tobase64("#session.key#:#session.secret#")#">
</cfhttpparam>
<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded;charset=UTF-8"></cfhttpparam>
<cfhttpparam type="body" value="grant_type=client_credentials"></cfhttpparam>
</cfhttp>
<cfreturn output>
</cffunction>
<cffunction name="search" access="public">
<cfset token="#deserializejson(token().filecontent)#" /><br>
<cfset access=tobase64(token.access_token)>
<cfset concate ="bearer "&"#access#">
<cfhttp url="https://api.twitter.com/1.1/users/search.json" method="get" result="searchResults" charset="utf-8">
<cfhttpparam type="header" name="Authorization" value="Bearer #token.access_token#"></cfhttpparam>
<cfhttpparam type="url" name="q" value="fb"></cfhttpparam>
</cfhttp>
<cfdump var="#searchResults#" abort="true" />
<cfreturn searchResults>
</cffunction>
</cfcomponent>