• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How can I get a URL from a bunch of code?

Guest
Jan 23, 2007 Jan 23, 2007

Copy link to clipboard

Copied

Hello,

I am performing a cfhttp (get) and it is returning the contents of a webpage. At the top contains the following code in the <head> tag:

<head><title>You have new Picture Mail!</title>
<!-- lsPictureMail-Share-aEAr4d7TmUP9t8s8L08x-comment
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF&#45;8&quot;?&gt;
&lt;shareMessage&gt;
&lt;messageContents type=&quot;PICTURE&quot;&gt;
&lt;messageText&gt;This is a test&lt;/messageText&gt;
&lt;mediaItems&gt;
&lt;mediaItem id=&quot;1&quot;&gt;
&lt;title&gt;&lt;/title&gt;
&lt;url&gt; http://yyyyyyyy.xxxxxxx.com/getMMBOXMessageMedia?id=Xw1004H8sLv6S3x76lVPYmsnJP2O20g3G1ktos3o40eowQu2...

&lt;urlExpiration&gt;2007&#45;01&#45;29T19:44:23Z&lt;/urlExpiration&gt;
&lt;/mediaItem&gt;
&lt;/mediaItems&gt;
&lt;/messageContents&gt;
&lt;/shareMessage&gt;

-->
<!-- lsPictureMail-UserInfo-aEAr4d7TmUP9t8s8L08x-comment
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF&#45;8&quot;?&gt;
&lt;UserInfo timestamp=&quot;2007&#45;01&#45;22T19:44:23.414+00:00&quot; originating_from_address=&quot;test@pm.sprint.com&quot;&gt;&lt;credential name=&quot;MDN&quot;&gt;3333333333&lt;/credential&gt;&lt;/UserInfo&gt;
-->
</head>

What I need to do is extract items like the URL, subject and originating_from_address. Would anyone suggest the best way to do this????

Thanks!!
TOPICS
Advanced techniques

Views

645

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Jan 23, 2007 Jan 23, 2007
Thank you for all of your help. I think I figured it out. Here is what I did for anyone else that might run into this issue.....


<cfsavecontent variable="thisstring">
#cfhttp.filecontent#
</cfsavecontent>
<cfset blah = REFindNoCase("THIS_IS_THE_BEGINNING(.*)THIS_IS_THE_END", thisstring, 1, True)>

<a href="#mid(thisstring, blah.pos[2], blah.len[2])#" target="_blank">Click to view Picture</a>

Votes

Translate

Translate
LEGEND ,
Jan 23, 2007 Jan 23, 2007

Copy link to clipboard

Copied

If the document is well formed XML you can use the XML capabilities of
ColdFusion, otherwise you will probably want to use regex functionality
to find what you are looking for.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 23, 2007 Jan 23, 2007

Copy link to clipboard

Copied

Thanks for replying. It really is not a well formed XML layout. It is in the header tag of an HTML page.

What I am doing is processing images that are sent in from mobile phones. It is all based on the carrier and some just send as an attachment while others send a branded webpage.

What is regex functionality??

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 23, 2007 Jan 23, 2007

Copy link to clipboard

Copied

What is regex functionality??

Regular Expressions - a syntax used to parse strings. One uses the
refind() and rereplace() functions in ColdFusion to utilize this syntax.

http://www.regular-expressions.info/reference.html

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 23, 2007 Jan 23, 2007

Copy link to clipboard

Copied

I am trying to use the "Start of String and End of String Anchors" to find the URL in the following section -

&lt;url&gt; http://pictures.sprintpcs.com/getMMBOXMessageMedia?id=Xw1004H8sLv6S3x76lVPYmsnJP2O20g3G1ktos3o40eowQ...

I am trying the following cfset ......

<CFSET tekst_striped = refind(cfhttp.filecontent, "^&lt;url&gt; http://*&lt;/url&gt;$","THIS IS THE ENTIRE URL")>

where ""^&lt;url&gt; http://" will find the start anchor and "*&lt;/url&gt;$" will be the end anchor. Would you say I am on the right track???

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 23, 2007 Jan 23, 2007

Copy link to clipboard

Copied

Would you say I am on the right track???

On the right track, but not quite there yet. But I am not enough of an
regex expert to help you much further.

You may get better help from a regex focused list. One I have used
before is the regex list at houseoffusion.com or the more general cftalk
list at the same site.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 23, 2007 Jan 23, 2007

Copy link to clipboard

Copied

Also, I am running CF 5.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 23, 2007 Jan 23, 2007

Copy link to clipboard

Copied

I am not sure what you are looking for but try the following to see if you can see the information you are trying to retrieve:

<cfdump var="#getHttpRequestData ()#" label="HTTP Request">
<cfdump var="#CGI#" label="CGI">

The first will show the content of the HTTP headers. The second will show you a structure of CGI variables that contains things like script name.

Cheers

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 23, 2007 Jan 23, 2007

Copy link to clipboard

Copied

Thanks. I tried that and it returned the vairables of the process page from our server. I use cfpop to get the emails that are sent in from mobile phone. Here is all the code from the page that is sent to me:

(attached)


Do you see the variables in the <head> tag? That is the information I need. Do you have any other ideas?

Thank you so much for your help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 23, 2007 Jan 23, 2007

Copy link to clipboard

Copied

I'm sorry, here is the right code with the variables in the head tag......

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 23, 2007 Jan 23, 2007

Copy link to clipboard

Copied

LATEST
Thank you for all of your help. I think I figured it out. Here is what I did for anyone else that might run into this issue.....


<cfsavecontent variable="thisstring">
#cfhttp.filecontent#
</cfsavecontent>
<cfset blah = REFindNoCase("THIS_IS_THE_BEGINNING(.*)THIS_IS_THE_END", thisstring, 1, True)>

<a href="#mid(thisstring, blah.pos[2], blah.len[2])#" target="_blank">Click to view Picture</a>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation