This seems trivial
<cfset username = urldecode(url.username, "utf-8")>
Where username in the URL = %F8yvind
Decoded username = �yvind
How do I get the corresponding html entity: ø?
I need to use the username as a lookup value in the db.
Thanks!
<cfset username = htmlEditFormat(urlDecode(URL.username, "utf-8"))>
Does this work?
Related
i am getting a 401 response from Asana with my request.
var url = "https://app.asana.com/api/1.0/users/me";
byte[] encodedByte = System.Text.ASCIIEncoding.ASCII.GetBytes(APIKey);
APIKey = Convert.ToBase64String(encodedByte);
WebRequest wrGETURL;
wrGETURL = WebRequest.Create(url);
wrGETURL.Headers.Add("Authorization: Basic " + APIKey);
string result;
using (StreamReader reader = new StreamReader(wrGETURL.GetResponse().GetResponseStream()))
{
result = reader.ReadToEnd();
}
return result;
The way HTTP basic auth works, you encode the username and password together as base64, separated by a colon. In the Asana API the key is the username and there is no password.
From the docs at https://asana.com/developers/documentation/getting-started/authentication#sts=API%20Keys :
Note: Most utilities and libraries that allow you to specify a username and password will handle proper encoding of the header for you. However, if you need to set the Authorization header manually, the header value is constructed by adding a colon (:) to the API key, then base64-encoding that string. You can read more on basic authentication if you need further details.
So, you should probably do:
byte[] encodedByte = System.Text.ASCIIEncoding.ASCII.GetBytes(APIKey + ":")
I want to get in ColdFusion 10 an URL parameter from CGI.QUERY_STRING by its name. How to do it without looping?
Any values passed in to a page via the query string are available in the URL scope.
Assume you have a query string that looks like http://mydomain.com?val1=42&val2=moo you would access the variables by referencing them as such
<cfset myVal1 = url.val1 />
<cfset myVal2 = url.val2 />
Or, in cfscript
myVal1 = url.val1;
myVal2 = url.val2;
To see all the values passed in via query string, you can also dump out the URL scope.
<cfdump var="#url#" />
or, in cfscript
writeDump( url );
Below I have this code:
string _strTemplate = _strDownloadTemplate + IDReq + "/" + _strFileName;
Uri url = new Uri(_strTemplate);
As you can see, I'm converting the strTemplate (which carries the link of a page that I need to sent by email for the user) to a URL Format. My email body has several fields that I'm replacing with the correct value:
strMailMessage = strMailMessage.Replace("_LinkTemplate", url);
I'm getting an error because the method string.Replace takes strings as parameters only.
Is there a way to get around this?
I was thinking about pass the URL value through my page (page.aspx) but if there's a way to do so through this method, it would be better for me.
Thanks!
Assuming this is C# and .NET, yes, String.Replace() works with strings.
Did you try:
strMailMessage = strMailMessage.Replace("_LinkTemplate", url.ToString());
I'm sure this is quite simple but I can't seem to get it right
In ColdFusionI've encrypted a querystring and then decrypted the CGI.Query_String value easily enough. I then have a single string which looks like a querystring. But I need to reference the querystring values as I would normally using URL. notation (for example).
How do I do this?
I've tried the code below but can't seem to parse the values out of the structure:
<cfscript>
myStruct = structNew();
for(i=1; i LTE listLen(decrypted,'&');i=i+1) {
structInsert(myStruct, i, listGetAt(decrypted,i,'&'));
}
</cfscript>
Any help appreciated.
UPDATE: (More info if I wasn't clear)
I'm sending data via CFLOCATION with an encrypted querystring. Just to hide some irrelevant info from the user. What I want to do is use the querystring information after it has been decrypted. But I can no longer use the ColdFusion URL structure. So I'm asking how do I parse the information from the decrypted string so I can use it (e.g. within a where clause of a SQL query or simply just display on the page).
Say my decrypted string is update=0&balance=1145.00
How do I go about using something like <cfoutput>#update#</cfoutput>?
If str is your querystring:
<CFSET str = "asdf=1&asd&as=3" />
<CFSET mystruct = structnew() />
<CFLOOP list="#str#" delimiters="&" index="i">
<CFSET key = listfirst(i,"=") />
<CFIF listlen(i,"=") GT 1>
<CFSET value = listlast(i,"=") />
<CFELSE>
<CFSET value = "" />
</CFIF>
<CFSET mystruct[key] = value />
</CFLOOP>
I'm working on twitter client for win8, using RestSharp ( http://restsharp.org/ ) and I have such problem:
When I'm posting new tweet with RestClient
var timeLine = new RestRequest("/1/statuses/update.json", Method.POST);
var txt = "Hello world";
timeLine.AddParameter("status", txt);
everything works excelent, but if I add more complex status like:
var txt = "Hello, World! What a nice day! #1May";
timeLine.AddParameter("status", txt);
I recieve 401 error. In debugger I saw, that status parameter in Signature Base String is incorrect. I have:
status%3DHello%2C%2520World%21%2520What%2520a%2520nice%2520day%21%2520%231May
and right string (from dev.twitter.com):
status%3DHello%252C%2520World%2521%2520What%2520a%2520nice%2520day%2521%2520%25231May
You can see, that punctuation marks ,!# and other encodes incorrect. How can I fix it?
Signature base generation and Encoding are in /Authenticators/OAuth/OAuthTools.cs
I have the same problem when I display twitter feed in website. Hence, I used this code to convert the text.
Regex.Replace(str, "#(.*?):", #"#http://twitter.com/#!/$1>$1:");