I am using MonkehTweet Coldfusion wrapper for Twitter Authentication. I have everything up working, but i cannot get my head around posting multiple images using the PostUpdateWithMedia function. I am relatively new to coldfusion, and learning it along the way. A simple call to PostUpdateWithMedia(status="", media="") would post to Twitter with an image, but how can i use this to post multiple images. The PostUpdateWithMedia function from MonkehTweet is,
<cffunction name="postUpdateWithMedia" access="public" output="false" hint="Updates the authenticating user's status. Request must be a POST. A status update with text identical to the authenticating user's current status will be ignored to prevent duplicates.">
<cfargument name="status" required="true" type="String" hint="The text of your status update. URL encode as necessary. Statuses over 140 characters will be forceably truncated." />
<cfargument name="media" required="true" type="string" hint="Up to max_media_per_upload files may be specified in the request, each named media[]. Supported image formats are PNG, JPG and GIF. Animated GIFs are not supported." />
<cfargument name="possibly_sensitive" required="false" type="boolean" default="false" hint="Set to true for content which may not be suitable for every audience." />
<cfargument name="in_reply_to_status_id" required="false" type="String" hint="The ID of an existing status that the update is in reply to." />
<cfargument name="lat" required="false" type="String" hint="The location's latitude that this tweet refers to." />
<cfargument name="long" required="false" type="String" hint="The location's longitude that this tweet refers to." />
<cfargument name="place_id" required="false" type="String" hint="A place in the world. These IDs can be retrieved from geo/reverse_geocode." />
<cfargument name="display_coordinates" required="false" type="String" hint="Whether or not to put a pin on the exact coordinates a tweet has been sent from." />
<cfargument name="checkHeader" required="false" type="boolean" default="false" hint="If set to true, I will abort the request and return the response headers for debugging." />
<cfargument name="timeout" required="false" type="string" default="#variables.instance.timeout#" hint="An optional timeout value, in seconds, that is the maximum time the cfhttp requests can take. If the time-out passes without a response, ColdFusion considers the request to have failed." />
<cfset var strTwitterMethod = '' />
<cfset arguments["media[]"] = arguments.media />
<cfset structDelete(arguments,'media') />
<cfset strTwitterMethod = getCorrectEndpoint('api') & 'statuses/update_with_media.json' />
<cfreturn genericAuthenticationMethod(timeout=getTimeout(), httpURL=strTwitterMethod,httpMethod='POST', parameters=arguments, checkHeader=arguments.checkHeader) />
</cffunction>
I have tried passing in multiple files as,
PostUpdateWithMedia(status="", media="", media=""); but it didnot work. But, I am passing in the multiple media arguments wrong. Can someone help me with how to pass in multiple media arguments.
Unfortunately, MonkehTweet does not include support for the Twitter API media/upload endpoint, which is required for multi-image Tweets - it only supports the deprecated statuses/update_with_media, which still works, but only supports a single image. I also noticed that the code still refers to 140 character Tweets, so it probably has not been updated for some time. I'm not aware of an alternative ColdFusion wrapper for the API, either, so this is something you would need to build for yourself.
Related
ELMAH generates an exception like below when a known process visits a non-existing URL on our website:
System.Web.HttpException: The controller for path '/manager/' was not
found or does not implement IController.
Whereas going to that non-existent URL from a browser generates a typical IIS 404.
The resource cannot be found. Description: HTTP 404. The resource you
are looking for (or one of its dependencies) could have been removed,
had its name changed, or is temporarily unavailable. Please review
the following URL and make sure that it is spelled correctly.
Requested URL: /manager
I know the process accessing these addresses is harmless, and want to stop receiving these specific emails being generated from a range of IP addresses. This is what I have in web.config but ELMAH email still comes through.
The URL filter seems to be working fine.
<elmah>
<security allowRemoteAccess="false" />
<errorMail from="elmah#mydomain.com" to="elmahlog#mydomain.com" async="true" smtpServer="mail.mydomain.com" smtpPort="25" useSsl="false" />
<errorFilter>
<test>
<and>
<equal binding="HttpStatusCode" value="500" type="Int32" />
<or>
<!--TrustWave scans our website with intentional bad addresses-->
<regex binding="Context.Request.ServerVariables['REMOTE_ADDR']" pattern="64.37.231.\d{1,3}" type="String" />
<!--Google looking for Digital Asset Links - well known statements the website wants to make-->
<regex binding="Context.Request.ServerVariables['URL']" pattern="/.well-known/assetlinks.json" type="String" />
<!--Apple devices searching for universal links - app-site association. we dont have an app.-->
<regex binding="Context.Request.ServerVariables['URL']" pattern="/.well-known/apple-app-site-association" type="String" />
</or>
</and>
</test>
</errorFilter>
</elmah>
Even though ELMAH email message looks like a 500 error occurred, the web.config really needed a 404 error code for the filter to work.
<equal binding="HttpStatusCode" value="404" type="Int32" />
instead of
<equal binding="HttpStatusCode" value="500" type="Int32" />
I have a site that uses CAS as a SSO solution and require all that access the site to be authenticated. To fulfill the regulations that our company has we need to create fully rendered snapshot copies of the site. I was thinking of using something like Httrack to accomplish this, but I need to get around the login. My plan was to exclude the IP address of the server running httrack, but I cannot seem to figure out how to configure this.
<sec:http name="contentSecurityFilterChain" use-expressions="true" access-decision-manager-ref="contentAccessDecisionManager" entry-point-ref="casAuthenticationEntryPoint">
<sec:custom-filter position="CAS_FILTER" ref="casAuthenticationFilter" />
<sec:logout logout-success-url="/logout.jsp" logout-url="/j_security_logout" invalidate-session="true" delete-cookies="sessionKey,userId,lastClient" />
<sec:access-denied-handler ref="accessDeniedHandler" />
<sec:custom-filter ref="requestSingleLogoutFilter" before="LOGOUT_FILTER" />
<sec:custom-filter ref="singleLogoutFilter" before="CAS_FILTER" />
<sec:csrf disabled="true" />
<sec:headers>
<!-- Enable hsts if possible. See http://tools.ietf.org/html/rfc6797 -->
<sec:hsts disabled="true" />
<sec:cache-control disabled="true" />
<sec:frame-options disabled="true" />
</sec:headers>
<sec:intercept-url pattern="/monitoring/**" access="hasRole('ROLE_MONITORING')" requires-channel="${security.channel.dispatcher}" />
channel="${security.channel.dispatcher}" />
<sec:intercept-url pattern="/api/login" access="hasRole('ROLE_AUTHENTICATED')" />
<sec:intercept-url pattern="/**" access="hasRole('ROLE_AUTHENTICATED') or hasIpAddress('192.168.123.123')" requires-channel="${security.channel.dispatcher}" />
</sec:http>
I tried the above as a first attempt (where 192.168.123.123 represents my excluded server), but the request still gets redirected to the SSO site before returning to the filter chain.
The closest I got in my various naive fiddlings was by adding a filter to the entry point that did not trigger the commence method; While it did not redirect the request, it only returned an empty page. I assume that is because by not calling the commence method the request was seen as not matching the filter group.
Is there a way to exclude an IP address from the security filters OR is there a better way of doing this?
Suggestions most welcomed!
I am using Primefaces Datatable component. This data table component creates a hidden field dynamically on the browser.
<input type="hidden" id="formId:activitydescription_selection" name="formId:activitydescription_selection" autocomplete="off" value="" />
The Primefaces datatable code is as follows
<p:dataTable id="activitydescription" var="type"
value="#{activityBean.activityList}" rows="#{activityBean.rowNo}" rowKey="#{type.activitySchemeId}"
selection="#{activityBean.activityDTO}"
emptyMessage="No value found with given criteria"
paginatorPosition="bottom" sortMode="single" paginator="#{empty activityBean.activityList ? 'false':'true' }"
dynamic="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
rowIndexVar="rowIndex">
Now when the page is submitted HIDV thinks the hidden field which is created dynamically on the browser is a case of hacking thereby redirecting to error page with the console log as
org.hdiv.logs.Logger log INVALID_PARAMETER_NAME;/hseadmin/pages/secured/admin/Layout.xhtml;**formId:activitydescription_selection**;;0:0:0:0:0:0:0:1;0:0:0:0:0:0:0:1;anonymous
In my hdiv-config.xml file i have modified the file so that HDIV ignore thi validation where this field occurs
<hdiv:paramsWithoutValidation>
<hdiv:mapping url=".*" parameters="formId:activitydescription_selection"/>
</hdiv:paramsWithoutValidation>
But no luck still the same console error and HDIV is redirecting to error page.
Can someone help me out on how to avoid these validations on HDIV?
try..
<property name="userStartParameters">
<list>
<value>hidden1Name</value>
<value>hidden2Name</value>
</list>
</property>
HDIV doesn't support the Primefaces components, only standard JSF components like <h:dataTable>.
http://www.hdiv.org/hdiv-documentation-single/doc.html
I need to call a stored procedure which gathers data during a specific window. For instance I send in a Timestamp representing now, and a window of 15 minutes and it will return all data within the last 15 minutes. Each time this procedure is called I need update the Timestamp representing now so that I avoid old data.
Is there anyway to achieve this?
My attempt with the "now" bean below is a failure as even though that bean is a prototype it's value is only ever retrieved once when the channel adapter is created.
The anonymised stored-proc-inbound-channel-adapter I currently have configured is below:
<int-jdbc:stored-proc-inbound-channel-adapter
channel="storedProcOutboundChannel" stored-procedure-name="dataWindowRetrieval"
data-source="dataSource" auto-startup="true" id=""
ignore-column-meta-data="false" is-function="false"
skip-undeclared-results="true" return-value-required="false">
<int:poller fixed-rate="60" time-unit="SECONDS"></int:poller>
<int-jdbc:parameter name="CurrentDateTime" type="java.sql.Timestamp" value="#{now}" />
<int-jdbc:parameter name="MinuteOffset" type="java.lang.Integer" value="3" />
<int-jdbc:parameter name="SomeOtherParameter" type="java.lang.Integer" value="4" />
<int-jdbc:parameter name="YetAnotherParameter" type="java.lang.Integer" value="15" />
<int-jdbc:returning-resultset name="theResults" row-mapper="org.springframework.jdbc.core.ColumnMapRowMapper" />
</int-jdbc:stored-proc-inbound-channel-adapter>
<bean id="now" scope="prototype" class="java.sql.Timestamp">
<constructor-arg value="#{ T(java.lang.System).currentTimeMillis()}" />
</bean>
Instead of value use expression="#now".
The value is only evaluated at initialization time.
I would like to iterate through an array and use the value taken from the array to put it within an http inbound endpoint. How would I be able to iterate through this array and take the value from the array to place it as a variable within the http inbound endpoint?
The code that I used to try was:
<flow name="foreachFlow1" doc:name="foreachFlow1">
<poll frequency="2000">
<foreach collection="#[groovy:['localhost:8082', 'localhost:8083']]"
doc:name="For Each">
<http:outbound-endpoint exchange-pattern="request-response"
address="http://#[payload]" method="GET" doc:name="HTTP" />
</foreach>
</poll>
</flow>
and I get the error
Invalid content was found starting with element 'poll'
Inbound endpoints are message sources and can not be parametrized the way you're describing.
To achieve your goal, trying a <poll> message source to wrap a foreach that uses http:outbound-endpoint to perform GET (#method) request-response (#exchange-apttern) interactions.
The trick is to bring the results for the HTTP calls back through the foreach, which by default do not do it. The following illustrate a potential approach:
<flow name="foreachFlow1">
<poll frequency="2000">
<processor-chain>
<set-variable variableName="httpResponses" value="#[[]]" />
<foreach collection="#[groovy:['localhost:8082', 'localhost:8083']]">
<http:outbound-endpoint
exchange-pattern="request-response" address="http://#[payload]"
method="GET" />
<expression-component>httpResponses.add(message.payloadAs(java.lang.String))
</expression-component>
</foreach>
</processor-chain>
</poll>
<logger level="INFO" message="#[httpResponses]" />
</flow>
<!-- Test server stubs -->
<flow name="server8082">
<http:inbound-endpoint exchange-pattern="request-response"
address="http://localhost:8082" />
<set-payload value="This is 8082" />
</flow>
<flow name="server8083">
<http:inbound-endpoint exchange-pattern="request-response"
address="http://localhost:8083" />
<set-payload value="This is 8083" />
</flow>