Permalink
Browse files

Updated repository to include current release (version 1.2.4) of monk…

…ehTweets
  • Loading branch information...
coldfumonkeh committed Feb 20, 2011
1 parent 1dacfd8 commit c80d79da9c3c07db7ffc2801167387f1b6392e7f
View
@@ -0,0 +1,85 @@
+<!---
+Name: Application.cfc
+Author: Matt Gifford AKA coldfumonkeh (http://www.mattgifford.co.uk)
+Date: 10.09.2010
+
+Copyright 2010 Matt Gifford AKA coldfumonkeh. All rights reserved.
+Product and company names mentioned herein may be
+trademarks or trade names of their respective owners.
+
+Subject to the conditions below, you may, without charge:
+
+Use, copy, modify and/or merge copies of this software and
+associated documentation files (the 'Software')
+
+Any person dealing with the Software shall not misrepresent the source of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+Usage: The monkehTweet component accepts two required parameters in the constructor;
+
+ 1) the consumer key
+ 2) the consumer secret
+
+both of which are obtained from the application page (if added) on http://dev.twitter.com
+
+All methods and parameters within the monkehTweet component are documented and hints provided to assist with use.
+
+--->
+<cfcomponent output="true">
+
+ <!--- Set up the application. --->
+ <cfscript>
+ this.Name = "monkehTweet_V1.2.4";
+ this.ApplicationTimeout = CreateTimeSpan( 0, 0, 1, 0 );
+ this.SessionManagement = true;
+ this.SetClientCookies = true;
+ //do this for CF7
+ this.mappings = structnew();
+ //do this for CF 8+
+ this.mappings['/com'] = GetDirectoryFromPath(GetCurrentTemplatePath()) & "/com";
+ </cfscript>
+
+
+ <cffunction name="OnApplicationStart" access="public" returntype="boolean" output="false">
+ <cfscript>
+ /*
+ If you are using this for a number of different accounts (allowing numerous users to acces Twitter)
+ you will need to specify only the consumerKey and consumerSecret
+
+ If you are using this for a single account only, set the oauthToken, oauthTokenSecret and your account name
+ in the init() method too, like this:
+
+ consumerKey = '',
+ consumerSecret = '',
+ oauthToken = '',
+ oauthTokenSecret = '',
+ userAccountName = '',
+ parseResults = true
+ */
+ application.objMonkehTweet = createObject('component',
+ 'com.coldfumonkeh.monkehTweet')
+ .init(
+ consumerKey = '< your consumer key >',
+ consumerSecret = '< your consumer secret >',
+ parseResults = true
+ );
+ return true;
+ </cfscript>
+ </cffunction>
+
+ <cffunction name="onrequestStart">
+ <cfscript>
+ if(structKeyExists(url, 'reinit')) {
+ onApplicationStart();
+ }
+ </cfscript>
+ </cffunction>
+
+</cfcomponent>
View
@@ -0,0 +1,42 @@
+<!---
+Name: authorize.cfm
+Author: Matt Gifford AKA coldfumonkeh (http://www.mattgifford.co.uk)
+Date: 10.09.2010
+
+Copyright 2010 Matt Gifford AKA coldfumonkeh. All rights reserved.
+Product and company names mentioned herein may be
+trademarks or trade names of their respective owners.
+
+Subject to the conditions below, you may, without charge:
+
+Use, copy, modify and/or merge copies of this software and
+associated documentation files (the 'Software')
+
+Any person dealing with the Software shall not misrepresent the source of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+--->
+
+<cfscript>
+ returnData = application.objMonkehTweet.getAccessToken(
+ requestToken = session.oAuthToken,
+ requestSecret = session.oAuthTokenSecret,
+ verifier = url.oauth_verifier
+ );
+
+if (returnData.success) {
+ //Save these off to your database against your User so you can access their account in the future
+ session['accessToken'] = returnData.token;
+ session['accessSecret'] = returnData.token_secret;
+ session['screen_name'] = returnData.screen_name;
+ session['user_id'] = returnData.user_id;
+}
+</cfscript>
+
+<a href="post.cfm">Send a post using monkehTweets and see the CFC in action</a>
@@ -0,0 +1,98 @@
+<!---
+Name: authDetails.cfc
+Author: Matt Gifford AKA coldfumonkeh (http://www.mattgifford.co.uk)
+Date: 10.09.2010
+
+Copyright 2010 Matt Gifford AKA coldfumonkeh. All rights reserved.
+Product and company names mentioned herein may be
+trademarks or trade names of their respective owners.
+
+Subject to the conditions below, you may, without charge:
+
+Use, copy, modify and/or merge copies of this software and
+associated documentation files (the 'Software')
+
+Any person dealing with the Software shall not misrepresent the source of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+--->
+<cfcomponent displayname="authDetails" output="false" hint="I am the authDetails component, and I contain the oauth consumer and access details.">
+
+ <cfproperty name="consumerKey" type="string" default="" />
+ <cfproperty name="consumerSecret" type="string" default="" />
+ <cfproperty name="oauthToken" type="string" default="" />
+ <cfproperty name="oauthTokenSecret" type="string" default="" />
+ <cfproperty name="userAccountName" type="string" default="" />
+
+ <cfset variables.instance = structNew() />
+
+ <cffunction name="init" access="public" output="false" returntype="com.coldfumonkeh.authDetails" hint="I am the constructor method for the authDetails class">
+ <cfargument name="consumerKey" required="true" type="string" hint="The consumer key generated by Twitter for the oAuth." />
+ <cfargument name="consumerSecret" required="true" type="string" hint="The consumer secret generated by Twitter for the oAuth." />
+ <cfargument name="oauthToken" required="true" type="string" hint="The access token (oauth_token) generated by Twitter for the oAuth." />
+ <cfargument name="oauthTokenSecret" required="true" type="string" hint="The access token secret (oauth_token_secret) generated by Twitter for the oAuth." />
+ <cfargument name="userAccountName" required="true" type="string" hint="The account name for the user. This is needed to access certain methods, including list-related functions." />
+ <cfscript>
+ variables.instance.consumerKey = arguments.consumerKey;
+ variables.instance.consumerSecret = arguments.consumerSecret;
+ variables.instance.oauthToken = arguments.oauthToken;
+ variables.instance.oauthTokenSecret = arguments.oauthTokenSecret;
+ variables.instance.userAccountName = arguments.userAccountName;
+ </cfscript>
+ <cfreturn this />
+ </cffunction>
+
+ <!--- MUTATORS --->
+ <cffunction name="setConsumerKey" access="package" output="false" hint="I set the consumer key generated by Twitter for the oAuth.">
+ <cfargument name="consumerKey" required="true" type="string" hint="The consumer key generated by Twitter for the oAuth." />
+ <cfset variables.instance.consumerKey = arguments.consumerKey />
+ </cffunction>
+
+ <cffunction name="setConsumerSecret" access="package" output="false" hint="I set the consumer secret generated by Twitter for the oAuth.">
+ <cfargument name="consumerSecret" required="true" type="string" hint="The consumer secret generated by Twitter for the oAuth." />
+ <cfset variables.instance.consumerSecret = arguments.consumerSecret />
+ </cffunction>
+
+ <cffunction name="setOAuthToken" access="package" output="false" hint="I set the consumer secret generated by Twitter for the oAuth.">
+ <cfargument name="oauthToken" required="true" type="string" hint="The access token (oauth_token) generated by Twitter for the oAuth." />
+ <cfset variables.instance.oauthToken = arguments.oauthToken />
+ </cffunction>
+
+ <cffunction name="setOAuthTokenSecret" access="package" output="false" hint="I set the consumer secret generated by Twitter for the oAuth.">
+ <cfargument name="oauthTokenSecret" required="true" type="string" hint="The access token secret (oauth_token_secret) generated by Twitter for the oAuth." />
+ <cfset variables.instance.oauthTokenSecret = arguments.oauthTokenSecret />
+ </cffunction>
+
+ <cffunction name="setUserAccountName" access="package" output="false" hint="I set the account name for the authenticated user.">
+ <cfargument name="userAccountName" required="true" type="string" hint="The account name for the user." />
+ <cfset variables.instance.userAccountName = arguments.userAccountName />
+ </cffunction>
+
+ <!--- ACCESSORS --->
+ <cffunction name="getConsumerKey" access="public" output="false" hint="I get the Twitter oAuth consumer key.">
+ <cfreturn variables.instance.consumerKey />
+ </cffunction>
+
+ <cffunction name="getConsumerSecret" access="public" output="false" hint="I get the Twitter oAuth consumer secret.">
+ <cfreturn variables.instance.consumerSecret />
+ </cffunction>
+
+ <cffunction name="getOAuthToken" access="public" output="false" hint="I get the Twitter oAuth token.">
+ <cfreturn variables.instance.oauthToken />
+ </cffunction>
+
+ <cffunction name="getOAuthTokenSecret" access="public" output="false" hint="I get the Twitter oAuth token secret.">
+ <cfreturn variables.instance.oauthTokenSecret />
+ </cffunction>
+
+ <cffunction name="getUserAccountName" access="public" output="false" hint="I get the user account name.">
+ <cfreturn variables.instance.userAccountName />
+ </cffunction>
+
+</cfcomponent>
Oops, something went wrong.

0 comments on commit c80d79d

Please sign in to comment.