Any experience with PHP and CURL??

Discussion about Schedules Direct grabber code and data formats.

Any experience with PHP and CURL??

Postby zbethem » Thu Feb 07, 2008 1:05 pm

I'm trying to retrieve TV listings for processing by my program in PHP. I at first tried using the nusoap_client, but returned to using CURL. Here's my code:

Code: Select all
$entry =<<<_XML_
       <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
       <SOAP-ENV:Body>
          <m:download xmlns:m="urn:TMSWebServices" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
             <startTime xsi:type="xsd:dateTime">2008-02-10T19:00:00Z</startTime>
             <endTime xsi:type="xsd:dateTime">2008-02-10T21:00:00Z</endTime>
          </m:download>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
_XML_;

   
$curl = curl_init("http://docs.tms.tribune.com/tech/tmsdatadirect/schedulesdirect/tvDataDelivery.wsdl");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
/*
 * ignore SSL Cert verification unless curl is setup to handle
 */
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($curl, CURLOPT_POSTFIELDS, $entry);
curl_setopt($curl, CURLOPT_USERPWD, $user.':'.$password);
curl_setopt($curl, CURLOPT_FRESH_CONNECT,true);

echo '<h2>Curl Results:</h2>';
print curl_exec($curl);
echo '<br><h2>Curl Error:</h2>';
print curl_error($curl);
print curl_close($curl);


This seems to get me somewhere, but the response is simply repeating documentation tags in the WSDL. Is my endpoint not correct? Thanks in advance.

Result of above:
A collection of messages that may be sent back by the server to the client. Messages are usually used by the server to notify the user of changes to their subscription caused by automatic changes in station's that are part of their subscription. For instance, messages are passed back if a lineup selected by the user is no-longer valid, if all the stations selected by the user has been removed as they are no longer valid ... An individual message that is passed back by the server. The time (in UTC) until which download requests will be blocked by the webservice. The time (in UTC) at which the webservice recommends that the client attempt another download request. A general success message to indicate a successful transaction. In general failures will result in SOAP Faults.
zbethem
 
Posts: 2
Joined: Thu Feb 07, 2008 12:55 pm

Re: Any experience with PHP and CURL??

Postby rmeden » Thu Feb 07, 2008 2:52 pm

I have a monitor script that is in PHP. I do this
Code: Select all
        $data_url   ='http://docs.tms.tribune.com/tech/tmsdatadirect/schedulesdirect/tvDataDelivery.wsdl';
        $start=gmdate("Y-m-d\TH:i:s\Z",time());
        $stop =gmdate("Y-m-d\TH:i:s\Z",time()+30);
        $client = new SoapClient($data_url, array('exceptions' => 0,
                                                  'login'      => $username,
                                                  'password'   => $password));
        $data = $client->download($start,$stop);
        }
rmeden
SD Board Member
 
Posts: 1497
Joined: Tue Aug 14, 2007 2:31 pm
Location: Cedar Hill, TX

Re: Any experience with PHP and CURL??

Postby zbethem » Thu Feb 07, 2008 3:10 pm

Dude, that's perfect!!!!! So happy now. Now I can move on to digesting the return array.

Thanks so much.
zbethem
 
Posts: 2
Joined: Thu Feb 07, 2008 12:55 pm


Return to Developers Corner

Who is online

Users browsing this forum: No registered users and 2 guests