function get_news_content() { $xml = <<<xl <?xml version="1.0" encoding="utf-8"?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://www.reuters.com/ns/2006/05/01/webservices/rkd/News_1" xmlns:ns2="http://www.w3.org/2005/08/addressing" xmlns:ns3="http://www.reuters.com/ns/2006/05/01/webservices/rkd/Common_1"> <env:Header> <ns2:To>http://api.rkd.reuters.com/api/2006/05/01/News_1.svc</ns2:To> <ns2:Action>http://www.reuters.com/ns/2006/05/01/webservices/rkd/News_1/RetrieveStoryML_1</ns2:Action> <ns3:Authorization> <ns3:ApplicationID>trkddemoappwm</ns3:ApplicationID> <ns3:Token>72a7ebf4b402280b1453ded824de6e966792cd79dd0c12d87f0ce21c048baa028db51e2924aa0e60713fea6d85e2f13bd9d521818383febbe0e61f824dae751798433a61b158f5eab068a909a1a8482687f1043cde1046a7c4aff1c0b00cdebb</ns3:Token> </ns3:Authorization> </env:Header> <env:Body> <ns1:RetrieveStoryML_Request_1 characters="zh-Hans"> <ns1:StoryMLRequest> <ns1:TimeOut>600</ns1:TimeOut> <ns1:StoryId>urn:newsml:reuters.com:20160105:nL3T14P3DH</ns1:StoryId> </ns1:StoryMLRequest> </ns1:RetrieveStoryML_Request_1> </env:Body> </env:Envelope> xl; $url = 'http://api.trkd.thomsonreuters.com/api/News/News.svc'; $header[] = 'Content-Type:application/soap+xml;'; $param = $xml; print_r(my_post($url, $param, $header)); }
function my_request($data = '') { $data = $data ? $data : $_REQUEST; $request = array(); foreach ($data as $key => $vtmp) { if (is_array($vtmp)) { $request[$key] = my_post($vtmp); } else { $request[$key] = fieldsclean($vtmp); } } return $request; }
function get_quotes($appid = 'trkddemoappwm', $token, $ric) { $xml = <<<xl <?xml version="1.0" encoding="utf-8"?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://www.reuters.com/ns/2006/05/01/webservices/rkd/Quotes_1" xmlns:ns2="http://www.w3.org/2005/08/addressing" xmlns:ns3="http://www.reuters.com/ns/2006/05/01/webservices/rkd/Common_1"> <env:Header> <ns2:To>http://api.rkd.reuters.com/api/2006/05/01/Quotes_1.svc</ns2:To> <ns2:Action>http://www.reuters.com/ns/2006/05/01/webservices/rkd/Quotes_1/RetrieveItem_3</ns2:Action> <ns3:Authorization> <ns3:ApplicationID>%s</ns3:ApplicationID> <ns3:Token>%s</ns3:Token> </ns3:Authorization> </env:Header> <env:Body> <ns1:RetrieveItem_Request_3> <ns1:ItemRequest Scope="List"> \t\t<ns1:Fields>GN_TXT16_4:CTBTR_1:SEC_ACT_1:CF_DATE:CF_TIME:GV3_TEXT</ns1:Fields> \t\t<ns1:RequestKey Name="%s" NameType="RIC"/> \t </ns1:ItemRequest> </ns1:RetrieveItem_Request_3> </env:Body> </env:Envelope> xl; #CF_YIELD:CF_CLOSE:CF_LAST $url = 'http://api.trkd.thomsonreuters.com/api/Quotes/Quotes.svc'; $header[] = 'Content-Type:application/soap+xml;'; $param = sprintf($xml, $appid, $token, $ric); $result = my_post($url, $param, $header); return $result; }