CFLib.org – Common Function Library Project

getTwitterUser(screenname)

Last updated June 7, 2011

author

Raymond Camden

Version: 2 | Requires: CF9 | Library: UtilityLib

Description:
Does a Twitter lookup for a user and returns all public information.

Return Values:
Returns a struct.

Example:

<cfdump var="#getTwitterUser('cfjedimaster')#">
<cfdump var="#getTwitterUser('cfjedimaster221920')#">

Parameters:

Name Description Required
screenname Screen name to look up. Yes

Full UDF Source:

<!---
 Does a simple Twitter lookup for a user.
 Added a success flag - thx Ben Nadel.
 
 @param screenname 	 Screen name to look up. (Required)
 @return Returns a struct. 
 @author Raymond Camden (ray@camdenfamily.com) 
 @version 2, June 7, 2011 
--->
<cffunction name="getTwitterUser" output="false" returnType="struct">
	<cfargument name="screenname" type="string" required="true">
	<cfset var httpResult = "">
	
	<!--- remove the @ if they included it. --->
	<cfif left(arguments.screenname,1) is "@">
		<cfset arguments.screenname = right(arguments.screenname, len(arguments.screenname)-1)>
	</cfif>
	
	<cfset var theUrl = "http://api.twitter.com/1/users/show.json?screen_name=#arguments.screenname#">
	
	<cfhttp url="#theUrl#" result="httpResult">
	<cfset var result = deserializeJSON(httpResult.filecontent)>
	
	<cfif structKeyExists(result, "error")>
		<cfset result.success = false>
	<cfelse>
		<cfset result.success = true>
	</cfif>

	<cfreturn result>	
</cffunction>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson