<?php $client = new SoapClient(dirname(__FILE__) . '/multiport.wsdl', array('trace' => true, 'exceptions' => false)); $response = $client->GetSessionId(array('userId' => 'user', 'password' => 'password')); echo $client->__getLastRequest();
function wfGetReutersData($query = false, $callback = "reutersRender", $count = 3) { $query = urldecode($query); $client = new SoapClient("http://ws.us.reuters.com/external/NewsDataSecure.asmx?wsdl", array('trace' => 1, 'exceptions' => 0, 'location' => "http://ws.us.reuters.com/external/NewsDataSecure.asmx")); $username = WISE_reuters_username; $password = WISE_reuters_password; $output = ""; if (!$session_id) { $response = $client->GetSessionId(array("userId" => $username, "password" => $password)); $variables = get_object_vars($response); $session_id = $variables["GetSessionIdResult"]; } $output = ""; $reuters_obj = array(); if (!$search_results) { $strHeaderComponent_Session = '<SoapAuthenticationHeader xmlns="http://www.reuters.com/"><SessionId>' . $session_id . '</SessionId></SoapAuthenticationHeader>'; $auth_var = new SoapVar($strHeaderComponent_Session, XSD_ANYXML, null, null, null); $header = new SoapHeader("http://www.reuters.com/", "SoapAuthenticationHeader", $auth_var); $client->__setSoapHeaders(array($header)); $search_results = $client->GetNewsSearch(array("keywords" => $query, "pgNum" => 0)); if (is_soap_fault($search_results)) { //echo $client->__getLastRequest(); //return "blah"; $output = $callback . "({});"; return $output; } $gotfrom = "service"; } else { $gotfrom = "memcached"; } $variables = get_object_vars($search_results); $results = get_object_vars($variables["GetNewsSearchResult"]); $news_story = $results["NewsStory"]; $reuters_obj["results"] = array(); $limit = sizeof($news_story) > $count ? $count : sizeof($news_story); for ($i = 0; $i < $limit; $i++) { $reuters_obj["results"][$i] = array(); $story = get_object_vars($news_story[$i]); $stocks = get_object_vars($story["StockSymbols"]); $reuters_obj["results"][$i]["ArticleUrl"] = $story["ArticleUrl"]; $reuters_obj["results"][$i]["Headline"] = $story["Headline"]; $reuters_obj["results"][$i]["Summary"] = substr($story["StoryBody"], 0, 300); $reuters_obj["results"][$i]["TimeStamp"] = $story["TimeStamp"]; $reuters_obj["results"][$i]["StockSymbols"] = array(); if (sizeof($stocks["anyType"]) == 1) { $reuters_obj["results"][$i]["StockSymbols"][0] = $stocks["anyType"]; } else { for ($j = 0; $j < sizeof($stocks["anyType"]); $j++) { $reuters_obj["results"][$i]["StockSymbols"][$j] = $stocks["anyType"][$j]; } } } $reuters_object = array("reutersResults" => $reuters_obj, "got_from" => $gotfrom, "results_count" => sizeof($reuters_obj["results"])); $reuters_json = jsonify($reuters_object); $output = $callback . "(" . $reuters_json . ");"; return $output; }