PHP - How To Get Response From Web Service Call
HI,
I need to know how to get the response objects from a webserve call. I call the following webservice: $params = array('mobiUser'=>"WJBASSON",'mobiPass'=>"83dop"); $soap = new SoapClient('http://172.18.22.182/csp/ampath/ReportGeneration.Mobi.Services.cls?WSDL'); $result = $soap->login($params); When I do var_dump($result) I receive the following: stdClass Object ( [loginResult] => stdClass Object ( [MobiRegUserID] => 34 [MobiRegUserName] => WJBasson ) ) I need to know how can I get the values of objects MobiRegUserID and MobiRegUserName ?? Similar TutorialsHi all, I'm a newbie in PHP trying to move away from the .net platform. I seem to have run into my first challenge passing a complex type back to my web service. The web service is a live test site to test against. I've tested the service on .net and it works fine...but I think I'm missing something as I try porting over to PHP? I've written some short code to keep it simple: <?php $SearchCriteria = array("ObjectType"=>1); $parameters['user'] = "johndoe1"; $parameters['password'] = "snowball"; $parameters['SearchCriteria'] = $SearchCriteria ; $client = new SoapClient("https://servicestest.mcquaig.com/mws.asmx?WSDL"); $result = $client->__soapCall('Find', $parameters); ?> ....against this portion of XML: <s:element name="Find"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="user" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="criteria" type="tns:SearchCriteria"/> </s:sequence> </s:complexType> </s:element> <s:complexType name="SearchCriteria"> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="AccountName" type="s:string"/> <s:element minOccurs="1" maxOccurs="1" name="ApplySharing" type="s:boolean"/> <s:element minOccurs="1" maxOccurs="1" name="CGType" type="s:int"/> <s:element minOccurs="0" maxOccurs="1" name="ClientRefID" type="s:string"/> <s:element minOccurs="1" maxOccurs="1" name="Composites" type="s:int"/> <s:element minOccurs="0" maxOccurs="1" name="ConfNo" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="Email" type="s:string"/> <s:element minOccurs="1" maxOccurs="1" name="Expired" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="ExpiryTSA" type="s:dateTime"/> <s:element minOccurs="1" maxOccurs="1" name="ExpiryTSZ" type="s:dateTime"/> <s:element minOccurs="0" maxOccurs="1" name="FirstName" type="s:string"/> <s:element minOccurs="1" maxOccurs="1" name="FormLangID" type="s:unsignedLong"/> <s:element minOccurs="1" maxOccurs="1" name="FunctionalArea" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="Gender" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="Industry" type="s:int"/> <s:element minOccurs="0" maxOccurs="1" name="JobTitle" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="LastName" type="s:string"/> <s:element minOccurs="1" maxOccurs="1" name="LastUsedTSA" type="s:dateTime"/> <s:element minOccurs="1" maxOccurs="1" name="LastUsedTSZ" type="s:dateTime"/> <s:element minOccurs="1" maxOccurs="1" name="NoRelated" type="s:boolean"/> <s:element minOccurs="1" maxOccurs="1" name="ObjectType" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="OrgID" type="s:unsignedLong"/> <s:element minOccurs="1" maxOccurs="1" name="Position" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="ProfileType" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="Recursive" type="s:boolean"/> <s:element minOccurs="1" maxOccurs="1" name="Status" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="Type" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="UnitsRemain" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="UnitsRemainGT" type="s:boolean"/> </s:sequence> </s:complexType> Nothing I seem to do works. I end up with the same error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Value does not fall within the expected range. Using NuSoap as: <?php require_once('lib/nusoap.php'); $SearchCriteria = array("ObjectType"=>1); $wsdlURL = "https://servicestest.mcquaig.com/mws.asmx?WSDL"; $soap = new nusoap_client($wsdlURL); $parameters['user'] = "johndoe1"; $parameters['password'] = "snowball"; $parameters['criteria'] = $SearchCriteria ; $result = $soap->call("Find", $parameters); if($error = $soap->getError()){ die($error);} ?> I get this error: soap:Client: Server did not recognize the value of HTTP Header SOAPAction: . I'm stumped and sure it's something small, but I just don't see what I'm missing?? Any suggestions are greatly appreciated!! Gary This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=353390.0 Okay, On my original problem, I have been able to authenticate with the web service login service, and extract a cookie as follows from the web-service: $s_Cookie = $agLoginService->agGetCookie(); $s_Cookie = AGSESSION=oxhbjcKtPw5sOymAD8m8KcKR6JL4i+TIE5mZxwOrXLwCRr8iTOvPxA==; Now, I create data access soapclient: $agDataService = new SoapClient($s_DataURL, $a_SoapOptions); //yes I know I should build my own class wrapper around soapClient, but I am trying to make sure I know what to build before I do next in the process I need to set the cookie for the data access service. I tried using: <b>$agDataService->__setCookie('cookie', $s_Cookie);</b> but I don't think it's right because when I call any of the service's functions, I get no data back. This is what their engineer had to say ( he is no help in php at all) This is a question referring the http headers. He needs to set the cookies as given in the examples on the wiki page. The cookie is specified in a response http header as: Set-Cookie. So the http headers he got back are correct. The cookie he has to set is AGSESSION=oxhbjcKtPw5sOymAD8m8KcKR6JL4i+TIE5mZxwOrXLwCRr8iTOvPxA==; There should be an api for setting the cookie if not there is one for setting the http header. Set the http header name for the request (cookie - notice that is different than what you get back from an http response - read the rfc spec for http for all of the details) then set the value. The semi colon at the end is the delimiter for http headers (in the rfc). That is all he needs to do if he gets back some login error that means the cookies did not get set correctly. Any ideas or help will be great. Thank you. A HTTP request is made to the server, Slim creates a Request and Response object, content in the Request is sent to another server using cURL via Guzzle, Guzzle returns its own Response, and content from Guzzle's response must be returned by the original Slim response. Would you recommend white-listing or black-listing response headers, and which specific headers? Similarly, would you recommend white-listing or black-listing the request headers sent via cURL, and which specific headers? Thanks <?php use Psr\Http\Message\ResponseInterface as Response; use GuzzleHttp\Psr7\Response as CurlResponse; class ApiResponder { public function delete(Response $httpResponse, CurlResponse $curlResponse) { return $this->proxy($httpResponse, $curlResponse); } //other public methods... private function proxy(Response $httpResponse, CurlResponse $curlResponse) { foreach($this->getResponseHeaders($curlResponse) as $name=>$value) { $httpResponse=$httpResponse->withHeader($name, $value); } return $httpResponse->withBody($curlResponse->getBody())->withStatus($curlResponse->getStatusCode()); } private function getResponseHeaders(Response $httpResponse):array { //Blacklist headers which should be returned to original client. TBD whether I should whitelist headers instead. $blacklist=['Date'=>null, 'Server'=>null, 'X-Powered-By'=>null, 'Access-Control-Allow-Origin'=>null, 'Access-Control-Allow-Methods'=>null, 'Access-Control-Allow-Headers'=>null, 'Set-Cookie'=>null]; return array_diff_key($curlResponse->getHeaders(), $blacklist); } /** * This method doesn't really exist in this class, but is just included to show which headers I am forwarding in the cURL request. */ private function getRequestHeaders($clientRequest):array { $whitelist=['connection'=>null,'accept'=>null,'accept-encoding'=>null,'accept-language'=>null,'content-type'=>null,'content-length'=>null]; return array_intersect_key($clientRequest->getHeaders(), $whitelist); } }
OVERVIEW: The code is about making call to the escreen web service using SOAP and Curl with client authentication required. Currently I am not getting any result only HTTP 403 and 500 errors. The call requires client authenticate cert to be on the callng site. CODE: $content = "<TicketRequest> <Version>1.0</Version> <Mode>Test</Mode> <CommitAction></CommitAction> <PartnerInfo> <UserName>xxxxxxxxxx</UserName> <Password>xxxxxxxxxxx</Password> </ PartnerInfo> <RequestorOrderID></RequestorOrderID> <CustomerIdentification> <IPAddress></IPAddress> <ClientAccount>xxxxxxxxxx</ClientAccount> <ClientSubAccount>xxxxxxxxxx</ClientSubAccount> <InternalAccount></InternalAccount> <ElectronicClientID></ElectronicClientID> </CustomerIdentification> <TicketAction> <Type></Type> <Params> <Param> <ID>4646</ID> <Value></Value> </Param> </Params> </TicketAction> </TicketRequest>"; $wsdl = "https://services.escreen.com/SingleSignOnStage/SingleSignOn.asmx"; $headers = array( "Content-type: text/xml;charset=\"utf-8\"", "Accept: text/xml", "Cache-Control: no-cache", "Pragma: no-cache", // "SOAPAction: \"\"", "Content-length: ".strlen($content), ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $wsdl); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_VERBOSE, '1'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $content); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '1'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, '1'); //curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //curl_setopt($ch, CURLOPT_HTTPHEADER, array('SOAPAction: ""')); curl_setopt($ch, CURLOPT_CAPATH, '/home/pps/'); curl_setopt($ch, CURLOPT_CAINFO, '/home/pps/authority.pem'); curl_setopt($ch, CURLOPT_SSLCERT, 'PROTPLUSSOL_SSO.pem'); curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'xxxxxxxxxxxx'); $output = curl_exec($ch); // Check if any error occured if(curl_errno($ch)) { echo 'Error no : '.curl_errno($ch).' Curl error: ' . curl_error($ch); } print_r($output); QUESTIONS: 1. I need to call the RequestTicket method and pass the XML string to it. I don't know how to do it here(pass the method name to call). 2. For client authentication they gave us three certs, one root cert, one intermediate cert and a client authentication cert PROTPLUSSOL_SSOpem(it was a .pfx file). Since we are on linux we converted them to pem . In curl calls I could not find way to how to include both the root cert and the intermediate cert ,so I combined them by making a new pem file and copying the intermediate cert and them the root cert and naming it authority.pem . I am not sure whether it works or not and would like your opinion. 3. For the current code Iam getting the error Error no : 77 Curl error: error setting certificate verify locations: CAfile: /home/pps/authority.pem CApath: /home/pps/ If I disable the curl error message,I am getting blank page with page title 403 - Forbidden. Access is denied. If I comment out the CURLOPT_CAPATH and CURLOPT_CAINFO lines it gives http 500 error page with the message as content and the following at the top. > HTTP/1.1 500 Internal Server Error. Cache-Control: private Content-Type: text/html Server: Microsoft-IIS/7.5 X-AspNet-Version: 1.1.4322 X-Powered-By: ASP.NET Date: Thu, 02 Sep 2010 14:46:38 GMT Content-Length: 1208 If I comment out as above and also CURLOPT_SSLCERT and CURLOPT_SSLCERTPASSWD it gives 403 error with the message as content. So I would request you to help me out by pointing out whats wrong with the current code. Thank you. This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=319682.0 I can call the following function successfully as a single php program // Acknowledge and clear the orders function ack($client, $merchant, $id) { $docs = array('string' => $id); $params = array('merchant' => $merchant, 'documentIdentifierArray' => $docs); $result = $client->call('postDocumentDownloadAck', $params); return $result; } with $result = ack($t, $merchant,'2779540483'); successful output [documentDownloadAckProcessingStatus] => _SUCCESSFUL_ [documentID] => 2779540483 I'm trying to figure out how to call this function as an object from another program. Trying the following gives error ***Call to a member function call() on a non-object*** function postDocumentDownloadAck($t, $merchant, $id) { $this->error = null; $docs = array('string' => $this->id); $params = array('merchant' => $this->merchant, 'documentIdentifierArray' => $docs); ** I've tried the following which does nothing $result = $this->soap->call('postDocumentDownloadAck', $params); ** I've tried the following - which gives error "Call to a member function call() on a non-object" $result = $this->t->soap->call('postDocumentDownloadAck', $params); if($this->soap->fault) { $this->error = $result; return false; } return $result; } *** calling program snippet for above function $merchant= array( "merchant"=> $merchantid, "merchantName" => $merchantname, "email"=> $login, "password"=> $password); $t = new AmazonMerchantAPI($merchantid, $merchantname, $login, $password); $documentlist= $t->GetAllPendingDocumentInfo('_GET_ORDERS_DATA_'); $docid = $documentlist['MerchantDocumentInfo'][$i]['documentID']; $docs = array('string' => $docid); $ackorders = $t->postDocumentDownloadAck($t, $merchant,$docs); Any ideas of what I'm doing wrong are greatly appreciated. I'm getting the following result from a web service call. I'd like to pass it to another page, possibly using sessions, and then access specific values on that page, such as FirstName.
stdClass Object ( [GetProspectAsJSONResult] => [ { "ProspectId": xxxxxx, "Keycode": "Test", "FirstName": "Test", "LastName": "Test", "Company": "Test","Email": null } ] )
I'm not sure what the best way to do this is.
Thanks!
Hi, guys. I just developed and published first version of 12framework for iOS which can call also PHP web services.
It is web service client which generates dynamic forms from web service results, and enables insert, update and delete of records. You can simply change result field type to text, memo, date, bool.
I also made some simple PHP web service to test functionallity of application, so I will really appreciate your feedback. iOS is locked platform, so 12framework provides possibility, to make some useful data forms that works as native application. Link: https://itunes.apple...88083?ls=1&mt=8
Hi Guys/Gals, I am new to PHP and when I say new, I mean I know a variable is $variable name... that is about it. I am a .Net developer, always was, now I have to learn some php. I have a .Net payment gateway service that I would like to reference from a php site. I was hoping anyone could point me in the right direction on how to go about adding a .Net Service and pointing to it in PHP. Please note this is a WPF service, thus it is a .svc page not a .asmx and it is hosted and running on iis on a server. Please some guidance? Any help would be appreciated. Hi everyone. I am looking at creating my application's back end with PHP, which returns all data with Jason or simplexml. I have tried Slim once, but think there should be something easier to use. Can anyone give me suggestions on what I can use which is easy to catch on, and maybe an example? Appreciate it. Kind regards Hi, I'm new to PHP and wondered if anyone could help... I am consuming an asmx webservice using PHP code. (Later to make a widget for wordpress). I can receive all the data, but it is in one very big xml file. I want to be able to convert this data, so I can make it more readable. Could really do with help as I don't have a clue how to convert it. ANy ideas? Hi! I need to retrieve data from a WCF Web Service and don't seem to be connecting when the "new SoapClient" is called. I am using php version 5.2. The service requires 2 Parmameters, an account ID and a comma separated email list. Can someone please tell me what I am doing wrong? Thanks! Code: [Select] <?php header('Content-Type: text/xml'); $client = new SoapClient('http://www.zbestlistings.com/WCF/Primedia.svc?wsdl'); $response = $client->GetPropertyXML(array( "AccountID" => "12807175152", "eMailList" => "Sheryl@Rentingslc.com, Tenants@Rpmwestvalley.com, Tom@Rpmsouthernutah.com" )); echo $response; ?> Hello
I am looking for a way to log all incoming requests to a nusoap web service to a file.. any suggestions?
Thanks
Curious how to set a returned value from a web service to a php variable? Code: [Select] $tid= $_POST['tid']; $client = new SoapClient("http://www.sitename.com/WebSvc.asmx?WSDL"); $result = $client->getName(array('tid'=>$tid)); echo json_encode($result); Returns this: Code: [Select] {"getNameResult":{"count":1,"results":{"TaggedText":{"tid":"001","text":"John Smith"}}}} How do I set a php variable $RetName to equal John Smith? I tried Code: [Select] $RetName = $text; But that didn't work. Any help is apprecaited. Thanks, sanchez I have service /usr/lib/systemd/system/socketserver.service defined as follows: [Unit] Description=Socket Server After=syslog.target [Service] ExecStart=/usr/bin/php /var/www/socket/server.php Restart=on-abort Restart=on-failure RestartSec=10s [Install] WantedBy=multi-user.target When hitting the following lines: $cmd="tshark -f 'port 1337' -i eno16780032 -a duration:4 -w /var/www/socket/tmp/test.pcap"; $status = exec($cmd, $output); syslog(LOG_INFO, 'results: '.json_encode($output).' status: '.($status?'success':'false')); I get the following: Jun 04 18:58:56 tapmeister.com php[43111]: Running as user "root" and group "root". This could be dangerous. Jun 04 18:58:56 tapmeister.com php[43111]: Capturing on 'eno16780032' Jun 04 18:58:56 tapmeister.com kernel: device eno16780032 entered promiscuous mode Jun 04 18:59:00 tapmeister.com kernel: device eno16780032 left promiscuous mode Jun 04 18:59:00 tapmeister.com php[43111]: 0 packets captured Jun 04 18:59:00 tapmeister.com Server[43111]: results: [] status: false Sure enough, exec('whoami') confirms I am running as root. Probably shouldn't be. How would you recommend configuring? PS. the three lines shown regarding tshark are executed via an asynchronous request and are not in the main loop. I created a functional class that shortens or expands the URL using google's shortening service. The class works but i feel like i can optimize it more but i don't know really how because i'm new in using classes. here is the code Code: [Select] define('GOOGLE_API_KEY', 'khjdaskjfsjkdhgfbsdhgsj'); define('GOOGLE_ENDPOINT', 'https://www.googleapis.com/urlshortener/v1'); class shortenGoogle { function shortenUrl($longUrl){ // initialize the cURL connection $ch = curl_init(sprintf('%s/url?key=%s', GOOGLE_ENDPOINT, GOOGLE_API_KEY)); // tell cURL to return the data rather than outputting it curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // create the data to be encoded into JSON $requestData = array( 'longUrl' => $longUrl ); // change the request type to POST curl_setopt($ch, CURLOPT_POST, true); // set the form content type for JSON data curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json')); // set the post body to encoded JSON data curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestData)); // perform the request $result = curl_exec($ch); curl_close($ch); // decode and return the JSON response return json_decode($result, true); } function expandUrl($shortUrl){ // initialize the cURL connection $ch = curl_init(sprintf('%s/url?key=%s&shortUrl='.$shortUrl.'', GOOGLE_ENDPOINT, GOOGLE_API_KEY)); // tell cURL to return the data rather than outputting it curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // tell cURL to ignore the SSL certificate in case it expires curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // perform the request $result = curl_exec($ch); curl_close($ch); // decode and return the JSON response return json_decode($result, true); } } $short = new shortenGoogle; $url = $short->shortenUrl('http://www.google.com/'); print_r($url); I'm able to consume a local WSDL into PHP, and pass/return basic data successfully, but when I attempt to pass in objects that correspond to a complextype in the WSDL, I get the following error: SoapFault exception: [soapenv:Server] javax.xml.ws.WebServiceException: com.ibm.websphere.sca.ServiceRuntimeException: An error occurred while parsing native data: The error message is: java.lang.IllegalArgumentException: Mismatched parameter count: expecting 1 items, but got more.. Caused By: java.lang.IllegalArgumentException: Mismatched parameter count: expecting 1 items, but got more.: caused by: An error occurred while parsing native data: The error message is: java.lang.IllegalArgumentException: Mismatched parameter count: expecting 1 items, but got more.. Caused By: java.lang.IllegalArgumentException: Mismatched parameter count: expecting 1 items, but got more. in C:\wamp\www\SugarCE\testSOAPShawn.php:65 Stack trace: #0 [internal function]: SoapClient->__call('establishIdenti...', Array) #1 C:\wamp\www\SugarCE\testSOAPShawn.php(65): SoapClient->establishIdentity(Object(stdClass), Object(stdClass)) #2 {main} Here is the snippets from the WSDL: Code: [Select] <xsd:element name="establishIdentity"> − <xsd:complexType> − <xsd:sequence> − <xsd:element name="processId" nillable="true" type="xsd:string"> − <xsd:annotation> − <xsd:documentation> Identifies a specific instance of the dialogue process. Returned from the start() operation. </xsd:documentation> </xsd:annotation> </xsd:element> − <xsd:element name="identityAttributes" nillable="true" type="bons1:IdentityAttributes"> − <xsd:annotation> − <xsd:documentation> Key identifying attributes of a program participant. </xsd:documentation> </xsd:annotation> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> Here is my code with comments where the error occurs: <?php set_time_limit(0); require_once('nusoap.php'); $client = new SoapClient('C:\wsdl\BenefitDeterminationProcess_BenefitDialogueServiceSOAP.wsdl', array('trace' => 1)); $start = $client->__soapCall('start', array(new SoapParam((string)'GenesisID', 'prefix')), array('soapaction' => 'C:\wsdl\BenefitDeterminationProcess_BenefitDialogueServiceSOAP\start')); $processID = $start; $exchange = $client->__soapCall('exchangeOptions', array(new SoapParam($processID, 'processId')), array('soapaction' => 'C:\wsdl\BenefitDeterminationProcess_BenefitDialogueServiceSOAP\exchangeOptions')); $identityAttributes = new StdClass(); $identityAttributes->IdentityAttributes = new StdClass(); $identityAttributes->IdentityAttributes->ssn = 41441414; $identityAttributes->IdentityAttributes->firstName = 'John2'; $identityAttributes->IdentityAttributes->lastName = 'Doe2'; $identityAttributes->IdentityAttributes->gender = 'MALE'; $identityAttributes->IdentityAttributes->birthDate = null; try{ $identity = $client->establishIdentity($processID, $identityAttributes); //ERROR } catch (SoapFault $f){ echo "ERROR!"; } $end = $client->__soapCall('stop', array(new SoapParam($processID, 'processId')), array('soapaction' => 'C:\wsdl\BenefitDeterminationProcess_BenefitDialogueServiceSOAP\stop')); ?> Any assistance is greatly appreciated! Thanks. I am trying to create a web service using restful service tonic frame work to pull data from my website www.serviidb.com and I can print_r the output to firefox poster. I am using SQL queries to pull the data form a mysql database. I would like to be able to select the query for the data I want at the beginning of the code and select the output format at the end. I am looking at having sections of the code to get "plugins", "video", "audio", and "user". I am thinking about use select case to determine the mysql query to run. I have programming exp in VB, basic and fortran. Here is the URL I am using for the get command. Code: [Select] http://serviidb.com/api/plugins here is the code I am using right now. Code: [Select] <?php class TaskDataManager { public static function get($taskId, $input){ echo $taskid . "\n"; //Connect To Database $hostname='hostname'; $username='username'; $password='password'; $dbname='dbname'; mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.'); mysql_select_db($dbname); //echo 'taskid: ' . $taskId . "\n"; if($taskId=="plugins"){ //echo $input . "\n"; $plgnsql='SELECT taxonomy_term_data.name, field_revision_field_revision.field_revision_value as version, file_managed.uri as URL' . ' FROM taxonomy_term_data ' . ' left join field_data_field_plugins on taxonomy_term_data.tid = field_data_field_plugins.field_plugins_tid ' . ' left join field_revision_field_revision on field_revision_field_revision.revision_id = field_data_field_plugins.revision_id ' . ' left join file_usage on field_data_field_plugins.entity_id = file_usage.id' . ' left join file_managed on file_usage.fid = file_managed.fid' . ' WHERE (field_data_field_plugins.bundle ="plugin")' . ' '; //$format='json' $result = mysql_query($plgnsql); //$mark =jsob_encode("plugins"); $plugins = array(); //echo $result . "\n"; //$response->addHeader('Content-type', 'application/json'); while($response = mysql_fetch_array($result, MYSQL_ASSOC)){ $response[URL] = substr_replace($response[URL],'http://serviidb.com/sites/default/files/',0,9); $reponse = json_encode($response); print_r ($reponse) . "\n"; } //print_r ($response) . "\n"; return true; } if($taskId=="video"){ echo $input . "\n"; //echo "started feed code" . "\n"; return true; } } } ?> Here is the output I am getting. I am trying to figure out how to get the json output to look like the second code below. Code: [Select] {"name":"Blip TV","version":"0","URL":"http:\/\/serviidb.com\/sites\/default\/files\/createplugin\/BlipTVUrlExtractor.groovy"}{"name":"CBS","version":"0","URL":"http:\/\/serviidb.com\/sites\/default\/files\/createplugin\/CBS.groovy"}{"name":"iPlayer (UK)","version":"1","URL":"http:\/\/serviidb.com\/sites\/default\/files\/createplugin\/IPlayer.groovy"}{"name":"4oD (UK)","version":"1","URL":"http:\/\/serviidb.com\/sites\/default\/files\/createplugin\/Channel4od.groovy"}{"name":"YouTube","version":"1","URL":"http:\/\/serviidb.com\/sites\/default\/files\/createplugin\/youtube.groovy"}{"name":"LiveFeeds","version":"3","URL":"http:\/\/serviidb.com\/sites\/default\/files\/createplugin\/livefeeds.groovy"}{"name":"GameSpot","version":"1","URL":"http:\/\/serviidb.com\/sites\/default\/files\/createplugin\/gamespot.groovy"} Want. Code: [Select] {"plugins":[{"name":"Blip TV", "version":0, "url":"http:\\serviidb.com/sites/default/files/Create Plugin/BlipTVUrlExtractor.groovy"},{"name":"CBS", ....}]} I am also trying to figure out how to get the output in the xml format also. Thanks is advance for the help. Hello, I use loads of different servers at work and they all run seperate services that I need to keep my stuff running. I want to build a simple webpage that will poll the services and display the current state by colour. EG have table that lists the services in green and have them turn red if the service stops unexpectedly. I can build the tables and stuff, I just don't know how to retrieve the state of a service. I've been messing about with some ideas but nothing is working. eg lets say I have two servers each with one service: service one | IP Address of server | RUNNING service two | IP Address of server | STOPPED Has anyone got any ideas? Thanks!! |