root/trunk/website/org/camden/blog/ping.cfc @ 5

Revision 5, 5.2 kB (checked in by DanWilson, 17 years ago)

Initial Commit Of ModelGlue? Website (upgrade to blogcfc 511)

Line 
1<!---
2        Name         : ping
3        Author       : Raymond Camden (mostly others wrote the methods)
4        Created      : December 16, 2005
5        Last Updated : December 20, 2005
6        History      : wrap xmlparse in icerocket with try/catch (rkc 12/20/05)
7        Purpose          : Ping, baby, ping!
8--->
9<cfcomponent displayName="Ping" output="false">
10       
11        <!---
12                  This function written by Dave Carabetta
13        --->
14        <cffunction name="pingIceRocket" output="false" returnType="boolean" access="public"
15                                hint="Ping IceRocket.com to add blog to IceRocket high-priority indexing queue">
16            <cfargument name="blogtitle" type="string" required="true">
17            <cfargument name="blogurl" type="string" required="true">
18           
19                <cfset var pingData = "" />
20                <cfset var pingDataLen = "" />
21                <cfset var isOK = false />
22                <cfset var iceRocketResponse = "" />
23                <cfset var pingResultString = "" />
24               
25                <cfoutput>
26                        <cfsavecontent variable="pingData">
27                        <?xml version="1.0" encoding="utf-8"?>
28                        <methodCall>
29                                <methodName>ping</methodName>
30                                <params>
31                                        <param>
32                                                <value>
33                                                        <string>#arguments.blogURL#</string>
34                                                </value>
35                                        </param>
36                                </params>
37                        </methodCall>
38                        </cfsavecontent>
39                </cfoutput>
40               
41                <cfset pingData = trim(pingData) />
42                <cfset pingDataLen = len(pingData) />
43               
44                <cfhttp method="post" url="http://rpc.icerocket.com/" port="10080" timeout="20" throwonerror="false">
45                   <cfhttpparam type="HEADER" name="User_Agent" value="BlogCFC" />
46                   <cfhttpparam type="HEADER" name="Host" value="#cgi.http_host#" />
47                   <cfhttpparam type="HEADER" name="Content-Type" value="text/xml" />
48                   <cfhttpparam type="HEADER" name="Content-Length" value="#pingDataLen#" />
49                   
50                   <cfhttpparam type="XML" value="#pingData#" />
51                </cfhttp>
52               
53                <cftry>
54                        <!--- Create an XML object using the RPC result string --->
55                        <cfset iceRocketResponse = xmlParse(cfhttp.fileContent) />
56                        <!--- Set the response string to a local variable for cleaner access --->
57                        <cfset pingResultString = iceRocketResponse.methodResponse.params.param.value.string.xmlText />
58                       
59                        <!--- Check the status code and the XML packet's method response to make sure things worked --->
60                        <cfif not compare(cfhttp.statuscode, "200 OK") and not compare(pingResultString, "Thanks for ping")>
61                           <cfset isOK = true />
62                        </cfif>
63                        <cfcatch>
64                                <cfset isOk = false>
65                        </cfcatch>
66                </cftry>
67                       
68                <cfreturn isOK />
69        </cffunction>
70
71        <!---
72                  This function written by Steven Erat, www.talkingtree.com/blog
73        --->
74        <cffunction name="pingTechnorati" output="false" returnType="boolean" access="public"
75                        hint="Ping Technorati.com to add blog to Technorati high-priority indexing queue">
76            <cfargument name="blogtitle" type="string" required="true">
77            <cfargument name="blogurl" type="string" required="true">
78               
79                <cfset var pingData = "">
80                <cfset var pingDataLen = "">
81               
82                <cfoutput>
83                   <cfsavecontent variable="pingData">
84                      <?xml version="1.0"?>
85                      <methodCall>
86                       <methodName>weblogUpdates.ping</methodName>
87                       <params>
88                       <param>
89                       <value>#arguments.blogTitle#</value>
90                       </param>
91                       <param>
92                       <value>#arguments.blogURL#</value>
93                       </param>
94                       </params>
95                      </methodCall>
96                   </cfsavecontent>
97                </cfoutput>
98
99                <cfset pingData = trim(pingData)>
100                <cfset pingDataLen = len(pingData)>
101                <cfhttp method="POST" url="http://rpc.technorati.com/rpc/ping" timeout="20" throwonerror="No">
102                   <cfhttpparam type="HEADER" name="User-Agent" value="BlogCFC"/>
103                   <cfhttpparam type="HEADER" name="Content-length" value="#pingDataLen#"/>
104                   <cfhttpparam type="XML" value="#pingData#"/>
105                </cfhttp>
106                <cfif cfhttp.statuscode contains "200" and cfhttp.filecontent contains "Thanks for the ping">
107                   <cfreturn true>
108                <cfelse>
109                   <cfreturn false>
110                </cfif>
111
112        </cffunction>   
113
114        <!---
115                This function written by Rob Gonda, www.robgonda.com/blog
116        --->
117        <cffunction name="pingWeblogs" output="false" returnType="boolean" access="public"
118                                hint="Ping weblogs.com to add blog to high-priority indexing queue">
119            <cfargument name="blogtitle" type="string" required="true">
120            <cfargument name="blogurl" type="string" required="true">
121                               
122                <cfset var pingData = "">
123                <cfset var pingDataLen = "">
124
125                <cfoutput>
126                <cfsavecontent variable="pingData">
127                        <?xml version="1.0"?>
128                        <methodCall>
129                                <methodName>weblogUpdates.ping</methodName>
130                                <params>
131                                        <param><value>#arguments.blogTitle#</value></param>
132                                        <param><value>#arguments.blogURL#</value></param>
133                                </params>
134                        </methodCall>
135                </cfsavecontent>
136                </cfoutput>
137
138                <cfset pingData = trim(pingData)>
139                <cfset pingDataLen = len(pingData)>
140
141                <cfhttp method="POST" url="http://rpc.weblogs.com/RPC2" timeout="20" throwonerror="No">
142                        <cfhttpparam type="HEADER" name="User-Agent" value="BlogCFC"/>
143                        <cfhttpparam type="HEADER" name="Content-length" value="#pingDataLen#"/>
144                        <cfhttpparam type="XML" value="#pingData#"/>
145                </cfhttp>
146
147                <cfif cfhttp.statuscode contains "200" and cfhttp.filecontent contains "<member><name>flerror</name><value><boolean>0</boolean>">
148                        <cfreturn true>
149                <cfelse>
150                        <cfreturn false>
151                </cfif>
152
153        </cffunction>   
154
155</cfcomponent>
Note: See TracBrowser for help on using the browser.