CFLib.org – Common Function Library Project

getTwitterUser(screenname)

Last updated June 08, 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>

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson