We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

How to send a request and receive the text from the HTTP response?

Loganathan Natarajan
on
Medium Priority
392 Views
Last Modified: 2012-08-14
I have an URL to send and receive some text from the HTTP response. How can I send and receive the response from http?

Basically, I need to grab some texts from the response on the url send.
Comment
Watch Question

Top Expert 2010

Commented:
<?php
$r = new HttpRequest('http://example.com/form.php', HttpRequest::METH_POST);
$r->setOptions(array('cookies' => array('lang' => 'de')));
$r->addPostFields(array('user' => 'mike', 'pass' => 's3c|r3t'));
$r->addPostFile('image', 'profile.jpg', 'image/jpeg');
try {
    echo $r->send()->getBody();
} catch (HttpException $ex) {
    echo $ex;
}
?>
http://php.net/manual/en/function.httprequest-send.php
Loganathan NatarajanLAMP Developer
CERTIFIED EXPERT

Author

Commented:
thanks, just a thought after going through cURL... can i use cURL to do this?
Loganathan NatarajanLAMP Developer
CERTIFIED EXPERT

Author

Commented:
What I need is specifically,  from this URl, I need to grad the flash object ...
http://www.saynow.com/playMsg.html?ak=Q1hwbUJsMTJiNTZJdVlZaVpGd1BmUT09
Vimal DMSenior Software Engineer
CERTIFIED EXPERT

Commented:
Hai,

It is easy in 'Ajax' way of doing things,

1) Having this file included zxml.src.js
2) Can search for the httpresponse and httprequest online

it is very simple implementation


                         or

There is also another way of making the ajax in the same way,but not including the file called zxml.src.js


Try
Most Valuable Expert 2011
Author of the Year 2014

Commented:
The code snippet contains the HTML returned from http://www.saynow.com/playMsg.html?ak=Q1hwbUJsMTJiNTZJdVlZaVpGd1BmUT09

Is the information you want in there?  If so, please point it out and we might be able to show you how to capture it.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
  <head>
    <meta name="title" content="Voice Message from speak2tweet " /> 
    <meta name="description" content="Sent via SayNow on 04/25/11 07:34 AM">
    <meta name="medium" content="mult">
    <link rel="video_src" href="http://www.saynow.com/flash/fb_player.swf?aikey=Q1hwbUJsMTJiNTZJdVlZaVpGd1BmUT09&autoplay=1&url=http://my.saynow.com&display_name=speak2tweet &icon_url=http://asset.saynow.com/images/defaultPic.jpg&sent_date=04/25/11 07:34 AM"/>
    <meta name="video_height" content="40" /> 
    <meta name="video_width" content="400" /> 
    <meta name="video_type" content="application/x-shockwave-flash" />
    <link rel="image_src" href="/images/default_pic.jpg"/>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Pragma-directive" content="no-cache" />
<meta http-equiv="Cache-directive" content="no-cache" />




  <title>Saynow: Voice Message from speak2tweet </title>


<!--[if IE 6]><link href="/stylesheets/sn/common/ie6only.css?1295653465" media="screen" rel="stylesheet" type="text/css" /><![endif]-->
<!--[if IE 7]><link href="/stylesheets/sn/common/ie7only.css?1295653465" media="screen" rel="stylesheet" type="text/css" /><![endif]-->
<!--[if IE]><link href="/stylesheets/sn/common/ie.css?1295653465" media="screen" rel="stylesheet" type="text/css" /><![endif]-->
<link rel="Shortcut Icon" href="/favicon.ico" />


    <link href="/stylesheets/cache/play_message_packaged.css?1296371933" media="screen" rel="stylesheet" type="text/css" />
    <script src="/javascripts/cache/play_message_packaged.js?1296371929" type="text/javascript"></script>
    


  <script type="text/javascript">
    
    $.fn.track.defaults.skip_internal = false;
    $.trackPage("UA-664032-1", { 
      
        page_url: "/play_message/jan25/Q1hwbUJsMTJiNTZJdVlZaVpGd1BmUT09",
      
      onload: false
    });
    $(function() {
      $.setVarEvent("not");
    });
 </script>


    <script type="text/javascript">
  $(document).ready( function(){
  $('.topRounded').corners("top");
  $('.bottomRounded').corners("bottom");
  $('.rounded').corners();
  });
</script>

    <script type="text/javascript" charset="utf-8"  src="http://bit.ly/javascript-api.js?version=latest&login=saynowweb&apiKey=R_bed0bb54135ce53d7d170a3e62e88718"></script>

    <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
  </head>
  <body>
    <script src="/javascripts/AC_RunActiveContent-1.7.js?1295653336" type="text/javascript"></script>

<script type="text/javascript">
AC_FL_RunContent(
  'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
  'width', '1',
  'height', '1',
  'src', '/flash/miniplayer',
  'quality', 'high',
  'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
  'align', 'middle',
  'id', 'miniplayer',
  'bgcolor', '#ffffff',
  'name', 'miniplayer',
  'allowFullScreen', 'false',
  'allowScriptAccess','sameDomain',
  'movie', '/flash/miniplayer',
  "FlashVars", "url=http://my.saynow.com"
);
</script>

<script src="/javascripts/sn/miniplayer.js?1295653335" type="text/javascript"></script>

    <div id="container">
      <div class="clear"></div>
      <div id="header">
        <div id="topnav">
<div class="links">
    
    <a href="http://www.saynow.com/info/learn_more">Learn More</a>
    <img src="/images/symbol_dot.gif" alt="dot" />
    <a href="/info/customers">Browse People</a>

    <img src="/images/symbol_dot.gif" alt="dot" />
    <a href="http://blog.saynow.com">Blog</a>
    <img src="/images/symbol_dot.gif" alt="dot" />
    
      <a href="http://www.saynow.com/sign_up.html">Sign Up</a>
      <img src="/images/symbol_dot.gif" alt="dot" />
      <strong><a href="http://www.saynow.com/account/login">Login</a></strong>
    
</div>

</div>
<div class="logo">
  <a href="/"><img src="/images/logo_50.png" class="logo" alt="SayNow" /></a>
</div>

      </div>
      <div class="clear"></div>
      <div id="profile">
        <!-- TODO  -->
<style type="text/css" media="screen">
.msgloading {
  padding-left:0px;
}
</style>

<script type="text/javascript" charset="utf-8">

$(function() {
  $('#embedText, #embedUrl').click(function() {
    $(this).focus();
    $(this).select();
  });
  $(".msgs-container").each(function() {
    $('#outgoingmsgs-container').
      prepend("<div class='msgloading'><div style='padding:1px'>Loading...</div></div>");
    $('#outgoingmsgs-container').
      load('/play_message/messages/' + 'jan25',
         function(response, status) {
           $('#outgoingmsgs-container div.msgloading').remove();
         });
  });
  var sender = "jan25";
  $.trackEvent("play_message/" + sender, "load", "aikey", "Q1hwbUJsMTJiNTZJdVlZaVpGd1BmUT09");
})

function trackFbConnect(id, aikey) {
  alog({'event':'install_playmsg_aikey', 'event_value':aikey}, function(){window.location = "http://apps.facebook.com/saynowtalk/users/" + id + "?r=playmsg"});
}
</script>


<div id="maincontent" style="width:960px;">

  <div id="title" class="topRounded">
    <h1>Message</h1>
  </div>

  <div id="main">

  <div id="msgsidebar">


  </div>

        <div id="content_item">
        <div class="userIcon"><a href="http://www.saynow.com/jan25"><img alt="Default_pic" src="/images/default_pic.jpg" /></a></div>
        <h2>Voice Message from <span class='username'><a href="http://www.saynow.com/jan25">speak2tweet </a></span></h2>
        <p class="msgMeta">

    04/25/11 07:34 AM, 04:05
        </p>

        <div class="audiowidget">
    
      <embed src='http://www.saynow.com/flash/sentplayer3.swf' quality="high" FlashVars="itemId=Q1hwbUJsMTJiNTZJdVlZaVpGd1BmUT09&autoplay=0&duration=04:05&url=http://my.saynow.com" bgcolor="#ffffff" wmode="opaque" width="320" height="65" name="player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>

    
        </div>

        <div class="msgactions">
        <span class="action">
        
        
                </span>

        <span class="action">
        
        </span>
        </div>


    <div class="clear"></div>
    <div class="clear"></div>
  </div>
 </div>
</div>

      </div>
    </div>
    <div class="clear"></div>
    <div id="footer">
      <div class="info">
  <p>
    <a href="http://www.saynow.com/info/about">About Us</a> |
    <a href="http://www.saynow.com/info/terms">Terms of Service</a> |
    <a href="http://www.saynow.com/info/privacy">Privacy Policy</a> |
	<a href="http://saynow.zendesk.com/" title="SayNow Support">Help and Support</a>

  </p>
  <p class="disclaimer">Text message notification works on most U.S. carriers. SayNow is free, but your cell phone carrier may charge you for receiving text messages or for long distance calls depending on the type of plan you have. To stop receiving text messages, text STOP to 729669 (SAYNOW). For help, text HELP.</p>
</div>

    </div>
    <script type="text/javascript">  FB.init("4da2c0f44542441be79550ef104a6644", "/xd_receiver.html"); </script>
  </body>
</html>

Open in new window

Mohamed AbowardaSenior Software Engineer
CERTIFIED EXPERT

Commented:
You only need to make AJAX request, I recommend you to use jQuery AJAX:
http://api.jquery.com/jQuery.ajax/

You might also use the normal way (without jQuery):
http://www.tizag.com/ajaxTutorial/ajax-javascript.php
Mohamed AbowardaSenior Software Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Most Valuable Expert 2011
Author of the Year 2014

Commented:
receive some text from the HTTP response

I guess the question I have is, what do you really want to retrieve?  Are you looking for text in the HTML string or looking for the HTTP response headers?  Let us know, thanks.
Loganathan NatarajanLAMP Developer
CERTIFIED EXPERT

Author

Commented:
@ Ray ... thanks for your inputs and clarification...

Yes, I am looking for text to parse from the HTML Source. I like to parse only the EMBED tag from the source. How can I retrieve?

@ Medo3337
I am trying in this way and like to parse only the EMBED tag. how to do further?
Most Valuable Expert 2011
Author of the Year 2014
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Loganathan NatarajanLAMP Developer
CERTIFIED EXPERT

Author

Commented:
thanks
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.