Hi Pranjal. Bob's code does work, and the main issue that I see in your
code is your use of ' = ' in HTTP headers when you just want a colon, as
in Bob's code.
Let us know if this helps. You have taken good steps towards
generalizing the creation of an OpenSRF message, for example. You can
add the best of your code to best of Bob's code, and when you have a
working combination, you may have the basis of a clean, general OpenSRF
PHP API binding.
Assuming Bob is cool with licensing his code under the GPL v2+, that is :-)
Thanks,
Lebbeous
On 05/29/2012 09:19 AM, Bob Wicksall wrote:
This example code works. It adds 2+2.
<?php
// *********************************************
//
// MATH Example!!! This one works!
//
// *********************************************
$catalog_host = 'evergreen.owwl.org';
$ch = curl_init();
$url = 'http://'.$catalog_host.'/osrf-http-translator';
$header = array(
'X-OpenSRF-service: opensrf.math'
);
$data =
'[{"__c":"osrfMessage","__p":{"threadTrace":0,"type":"REQUEST","payload":{"__c":"osrfMethod","__p":{"method":"add","params":[2,2]}},"locale":"en-US"}}]';
$data = 'osrf-msg=' . urlencode($data);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$server_result = curl_exec($ch);
echo '<pre>';
echo $server_result;
echo '</pre>';
echo '<HR />';
echo $data;
curl_close($ch);
?>
Bob Wicksall
Systems Administrator
Pioneer Library System
2557 State Rt. 21
Canandaigua, New York 14424
Voice: (585) 394-8260
Fax: (585) 394-1935
----- Original Message -----
From: "Pranjal Prabhash"<[email protected]>
To: [email protected]
Sent: Sunday, May 27, 2012 7:18:33 AM
Subject: [OPEN-ILS-DEV] error connecting to openSRF service
Hello,
I went through the article "
http://www.open-ils.org/dokuwiki/doku.php?id=opensrf_over_http ". I
have changed my "basic openSRF php client" code. Still I am unable
to connect to the service. I really need some help connecting to the
service.
Thankyou
Regards
Pranjal
--
Lebbeous Fogle-Weekley
| Software Developer
| Equinox Software, Inc. / Your Library's Guide to Open Source
| phone: 1-877-OPEN-ILS (673-6457)
| email: [email protected]
| web: http://www.esilibrary.com