Skip to Content.
Sympa Menu

grouper-users - Re: [grouper-users] Grouper-WS and PHP

Subject: Grouper Users - Open Discussion List

List archive

Re: [grouper-users] Grouper-WS and PHP


Chronological Thread 
  • From: mohan shamachar <>
  • To:
  • Subject: Re: [grouper-users] Grouper-WS and PHP
  • Date: Tue, 22 Jan 2013 11:27:54 -0500 (EST)

Hello,

In order to work around the AJAX/Callback data parsing issue, I tried using
PHP to make the grouper-ws calls and return the data back to the browser.
Now, the data I get back is in XHTML form, even though I specify JSON in my
url.

what do I need to do to make this call return JSON. Thank you.

best,
mohan

Here's the php code:

function grouper_rest_request() {
$url = 'http://' . $this->user . ':' . $this->password . '@' .
$this->host . ':8080/grouper-ws/servicesRest/json/v2_1_000/subjects';

$subjectId = 'testuser';
$request = '<WsRestGetGroupsRequest>
<subjectLookups>
<WsSubjectLookup>
<subjectId>'.$subjectId.'</subjectId>
</WsSubjectLookup>
</subjectLookups>
</WsRestGetGroupsRequest>';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml;
charset=UTF-8'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 2);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$response = curl_exec($ch);
$error = curl_error($ch);
$info = curl_getinfo($ch);
if ($response !== FALSE) {
if ( ($error != '') or ($info['http_code'] >= 300) ) $response
= FALSE;
}
if ($response == FALSE) {
throw new Exception('Could not execute grouper webservice
request: [error: ' . $error . '] [http code: ' . $info['http_code'] . ']');
}
curl_close($ch);
return $response;
}



Archive powered by MHonArc 2.6.16.

Top of Page