Data from URL to Web service Client (REST) Drupal
Data from URL to Web service Client (REST) Drupal
$json = drupal_http_request('http://maps.google.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false');
$decode = json_decode($json->data, TRUE);
Using cURL
$url = 'http://localhost/rest/04/library/book.php';
$client = curl_init($url);
curl_setopt($client, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($client);
curl_close($client);
Consume REST web service in code using Web service client
https://www.drupal.org/node/1114320
https://www.drupal.org/node/1114320
$service = wsclient_service_load('your ws service'); $account = new stdClass; $account->name ='your user'; $account->pass_raw ='your pass'; // For own HTTPS certificates. $curl_options[CURLOPT_SSL_VERIFYPEER] = FALSE; // For own HTTP authorization. $curl_options[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC; $curl_options[CURLOPT_USERPWD] = $account->name . ':' . $account->pass_raw; $service->settings['curl options'] = $curl_options; try { $result = $service->your_method(); } catch (WSClientException $e) { watchdog('wsclient', $e->__toString()); return null; } return $result;
Post a Comment