I'm trying to use the library jmathai/twitter-async to send tweets, but I get an exception with no message :
//not logged in:
if($oauth_token == '')
{
try
{
$authorizationUrl = $twitterObj->getAuthorizeUrl();
/*
if (isset($authorizationUrl))
{
$twitterMessage = '<p>'._('twitter.signin.message').' : '.
'<a href="'. $authorizationUrl. '">'.
'<img class="signin" src="images/sign-in.png" /></a></p>';
}
else
{
$twitterMessage .= '<p>'._('twitter.error.message').' (error 1)</p>';
}
*/
}
catch(EpiTwitterException $e)
{
$twitterMessage .= 'epiError '.$e->getCode() . ' ' . $e->getMessage();
}
catch(EpiOAuthException $e)
{
$twitterMessage .= 'oAutherror: '$e->getCode() . ' ' . $e->getMessage();
}
}
This echoes "oAutherror: 0 "
Here's the result of var_dump($e->getTrace()); :
array(3) {
[0]=>
array(6) {
["file"]=>
string(70) "/.../lib/jmathai-twitter-async/EpiOAuth.php"
["line"]=>
int(404)
["function"]=>
string(5) "raise"
["class"]=>
string(17) "EpiOAuthException"
["type"]=>
string(2) "::"
["args"]=>
array(2) {
[0]=>
object(EpiCurlManager)#3 (2) {
["key:private"]=>
string(14) "Resource id #8"
["epiCurl:private"]=>
object(EpiCurl)#2 (9) {
["mc:private"]=>
resource(7) of type (curl)
["msgs:private"]=>
NULL
["running:private"]=>
NULL
["execStatus:private"]=>
NULL
["selectStatus:private"]=>
NULL
["sleepIncrement:private"]=>
float(1.1)
["requests:private"]=>
array(1) {
["Resource id #8"]=>
resource(8) of type (Unknown)
}
["responses:private"]=>
array(1) {
["Resource id #8"]=>
array(6) {
["data"]=>
bool(false)
["code"]=>
int(0)
["time"]=>
float(0)
["length"]=>
float(0)
["type"]=>
bool(false)
["url"]=>
string(43) "https://api.twitter.com/oauth/request_token"
}
}
["properties:private"]=>
array(5) {
["code"]=>
int(2097154)
["time"]=>
int(3145731)
["length"]=>
int(3145743)
["type"]=>
int(1048594)
["url"]=>
int(1048577)
}
}
}
[1]=>
bool(false)
}
}
[1]=>
array(6) {
["file"]=>
string(70) "/.../lib/jmathai-twitter-async/EpiOAuth.php"
["line"]=>
int(53)
["function"]=>
string(5) "__get"
["class"]=>
string(16) "EpiOAuthResponse"
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
string(11) "oauth_token"
}
}
[2]=>
array(6) {
["file"]=>
string(44) "/.../main.inc.php"
["line"]=>
int(29)
["function"]=>
string(15) "getAuthorizeUrl"
["class"]=>
string(8) "EpiOAuth"
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
The problem seems to have gona way when I removed the certificate from the folder (file named ca_bundle.crt).
See https://github.com/jmathai/twitter-async/issues/134
Related
I have an array returned from Google Maps, that looks like this:
array(4) {
["destination_addresses"]=> array(4) {
[0]=> string(19) "Walsall WS2 9PS, UK"
[1]=> string(19) "Walsall WS2 9PS, UK"
[2]=> string(19) "Walsall WS2 9PS, UK"
[3]=> string(26) "Wolverhampton WV10 0QP, UK"
}
["origin_addresses"]=> array(1) {
[0]=> string(18) "Stone ST15 0FL, UK"
}
["rows"]=> array(1) {
[0]=> array(1) {
["elements"]=> array(4) {
[0]=> array(3) {
["distance"]=> array(2) {
["text"]=> string(7) "41.9 km"
["value"]=> int(41947)
}
["duration"]=> array(2) {
["text"]=> string(7) "36 mins"
["value"]=> int(2134)
}
["status"]=> string(2) "OK"
}
[1]=> array(3) {
["distance"]=> array(2) {
["text"]=> string(7) "41.9 km"
["value"]=> int(41947)
}
["duration"]=> array(2) {
["text"]=> string(7) "36 mins"
["value"]=> int(2134)
}
["status"]=> string(2) "OK"
}
[2]=> array(3) {
["distance"]=> array(2) {
["text"]=> string(7) "41.9 km"
["value"]=> int(41947)
}
["duration"]=> array(2) {
["text"]=> string(7) "36 mins"
["value"]=> int(2134)
}
["status"]=> string(2) "OK"
}
[3]=> array(3) {
["distance"]=> array(2) {
["text"]=> string(7) "40.9 km"
["value"]=> int(40924)
}
["duration"]=> array(2) {
["text"]=> string(7) "41 mins"
["value"]=> int(2458)
}
["status"]=> string(2) "OK"
}
}
}
}
["status"]=> string(2) "OK"
}
I want to be able to run through the array, and print the destination address and the distance and time values.
This prints the destination addresses ok:
$length=count($properties);
for($a=0;$a<$length;$a++)
{
echo '</br>Index is ' . $a . ' | id is ' . $index[$a] . ' | destination is ' . $properties["destination_addresses"][$a] . ' | time is ';
}
But I can't figure out how to print the rest. I've been banging my head against the wall all night!
Thank you in anticipation.
To loop over all these journeys and print the distance and time for each potential journey, create a foreach loop and then use the $idx to address the subordinate parts of the muleiple arrays
foreach( $destination['destination_addresses'] as $idx => $to ) {
if ( $destination['rows'][0]['elements'][$idx]['status'] == 'OK' ) {
echo 'Going from ' . $destination['origin_addresses'][0];
echo ' To ' . $to;
echo ' Distance ' . $destination['rows'][0]['elements'][$idx]['distance']['text'];
echo ' Duration ' . $destination['rows'][0]['elements'][$idx]['duration']['text'];
} else {
//whatever you do if the status is not OK
}
}
array(2) { [0]=> array(2) { ["name"]=> string(16) "Daerah Pertanian" ["sub"]=> array(6) { [0]=> array(2) { ["name"]=> string(5) "Sawah" ["value"]=> string(3) "145" } [1]=> array(2) { ["name"]=> string(18) "Sawah Pasang Surut" ["value"]=> string(3) "455" } [2]=> array(2) { ["name"]=> string(6) "Ladang" ["value"]=> string(3) "678" } [3]=> array(2) { ["name"]=> string(10) "Perkebunan" ["value"]=> string(3) "688" } [4]=> array(2) { ["name"]=> string(19) "Perkebunan Campuran" ["value"]=> string(3) "966" } [5]=> array(2) { ["name"]=> string(16) "Tanaman Campuran" ["value"]=> string(3) "565" } } } [1]=> array(2) { ["name"]=> string(22) "Daerah Bukan Pertanian" ["sub"]=> array(2) { [0]=> array(2) { ["name"]=> string(18) "Hutan Lahan Kering" ["sub"]=> array(2) { [0]=> array(2) { ["name"]=> string(25) "Hutan Lahan Kering Primer" ["value"]=> string(3) "566" } [1]=> array(2) { ["name"]=> string(27) "Hutan Lahan Kering Sekunder" ["value"]=> string(3) "255" } } } [1]=> array(2) { ["name"]=> string(17) "Hutan Lahan Basah" ["sub"]=> array(2) { [0]=> array(1) { ["name"]=> string(24) "Hutan Lahan Basah Primer" } [1]=> array(1) { ["name"]=> string(26) "Hutan Lahan Basah Sekunder" } } } } } }
I have an array like I mention above, so I want to print out every "name" key including the index (number) of it's array parent,
for example when I print out "Tanaman Campuran" so all index parent is (0)(5) and when I print "Hutan Lahan Basah Sekunder" the index parent is (1)(1)(1)
how can I achieve it?
here is some recursive function that I've tried
$GLOBALS['all'] = '';
function printout($arr){
foreach ($arr as $ia=>$a){
if(is_array($a)){
foreach ($a as $ib=>$b){
if(is_array($b)){
printout($b);
}
else{
if ($ib == 'name') {
$GLOBALS['all'] .= $ia;
echo '<tr>';
echo '<td>' . $b . ' (' . $ia . ')</td>';
echo '</tr>';
$GLOBALS['all'] = '';
}
}
}
}
}
}
*sorry for my bad explanation, I hope you guys can understand it
You could use the following function:
function search(array $array, $name)
{
foreach ($array as $key => $entry) {
if ($entry['name'] === $name) {
return [$key];
}
if (isset($entry['sub']) && $found_keys = search($entry['sub'], $name)) {
return array_merge([$key], $found_keys);
}
}
return null;
}
It returns:
if the value was directly found, an array of one containing the associated index,
if it wasn't but was found in any descendant item, an array merging its index with the indices of said descendant,
null if it wasn't found in that part of the tree.
Note: if a given name is present several times, it will only find the first occurrence.
Demo: https://3v4l.org/1hGr1
I have written below lines of code
public function shiftarray($cursor, $arg)
{
$keyarguments = array("first_name","roll_no");
$arrayStudents =array();
foreach ($cursor as $k => $row)
{
foreach ($keyarguments as $key)
{
if (strcasecmp($row[$key], $arg) == 0)
{
array_unshift($arrayStudents, $row);
}
else
{
}
}
}
return $arrayStudents;
}
I have array of students in $cursor like
{ [0]=> array(50) { ["_id"]=> object(MongoId)#23 (1) { ["$id"]=> string(24) "58131c7799fbad4c1d000202" } ["student_id"]=> float(2) ["registration_temp_perm_no"]=> string(1) "1" ["roll_no"]=> float(1) ["admission_date"]=> string(10) "01/07/2016" ["first_name"]=> string(7) "Neil" ["middle_name"]=> string(4) "David" ["last_name"]=> string(6) "Stephan" ["dob"]=> string(10) "12/03/1981" ["gender"]=> string(6) "Female" ["blood_group"]=> string(2) "A+" ["birth_place"]=> string(11) "Sadar Bazar" ["nationality"]=> string(6) "Indian" ["language"]=> string(7) "English" ["religion"]=> string(8) "Agnostic" ["address_line1"]=> string(20) "4148 Hazelcrest Hill" ["address_line2"]=> string(20) "22883 Memorial Place" ["city"]=> string(11) "Sadar Bazar" ["state"]=> string(13) "Uttar Pradesh" ["pincode"]=> string(6) "190010" ["country"]=> string(5) "India" ["phone1"]=> string(10) "9039180419" ["phone2"]=> string(10) "7681559402" ["email"]=> string(24) "educianstudent#gmail.com" ["is_sms_enabled"]=> string(3) "Yes" ["is_active"]=> int(1) ["has_finished"]=> int(0) ["student_category"]=> string(1) "5" ["course"]=> string(24) "58131c7099fbad4c1d0001c2" ["Biometric_ID"]=> string(1) "1" ["siblings"]=> string(14) "Cynthia Taylor" ["guardian_name"]=> string(14) "Cynthia Taylor" ["guardian_occupation"]=> string(13) "Senior Editor" ["guardian_qualification"]=> string(20) "Research Assistant I" ["guardian_email_id"]=> string(23) "educianparent#gmail.com" ["gaurdain_contact_details"]=> string(10) "9419513603" ["guardian_relationship"]=> string(6) "Father" ["height"]=> string(3) "4.9" ["weight"]=> string(4) "34.9" ["allergies"]=> string(0) "" ["batch"]=> int(2) ["academicyear"]=> string(4) "2015" ["batchhistory"]=> array(1) { [0]=> array(5) { ["batchid"]=> float(2) ["academic_year"]=> string(4) "2015" ["course"]=> string(24) "58131c7099fbad4c1d0001c2" ["sequenceno"]=> int(1) ["courseId"]=> object(MongoId)#24 (1) { ["$id"]=> string(24) "58131c7099fbad4c1d0001c2" } } } ["uploads"]=> array(1) { ["profile_pic"]=> string(39) "58131c7799fbad4c1d000202schoolgirl2.jpg" } ["created_at"]=> NULL ["updated_at"]=> string(0) "" ["routearray"]=> array(2) { [0]=> array(5) { ["routeid"]=> int(2) ["academicyear"]=> string(4) "2016" ["current"]=> int(0) ["vehicleno"]=> string(9) "JK01S8764" ["dateofassignment"]=> string(10) "09/28/2016" } [1]=> array(5) { ["routeid"]=> int(3) ["academicyear"]=> string(4) "2016" ["current"]=> int(1) ["vehicleno"]=> string(9) "JK01S8764" ["dateofassignment"]=> string(10) "11/17/2016" } } ["HostelAlloted"]=> array(7) { ["Food Preferences"]=> string(4) "Both" ["Hostel"]=> object(MongoId)#25 (1) { ["$id"]=> string(24) "58138aee99fbade41e000031" } ["Floor"]=> string(7) "Floor_1" ["RoomNumber"]=> int(11) ["Approved"]=> string(3) "yes" ["Approved On"]=> object(MongoDate)#26 (2) { ["sec"]=> int(1472322600) ["usec"]=> int(0) } ["Academic Year"]=> string(4) "2016" } ["HostelAllotmentHistory"]=> array(1) { [0]=> array(7) { ["Food Preferences"]=> string(4) "Both" ["Hostel"]=> object(MongoId)#27 (1) { ["$id"]=> string(24) "58138aee99fbade41e000031" } ["Floor"]=> string(7) "Floor_1" ["RoomNumber"]=> int(11) ["Approved"]=> string(3) "yes" ["Approved On"]=> object(MongoDate)#28 (2) { ["sec"]=> int(1472322600) ["usec"]=> int(0) } ["Academic Year"]=> string(4) "2016" } } ["courseId"]=> object(MongoId)#29 (1) { ["$id"]=> string(24) "58131c7099fbad4c1d0001c2" } }
...
...
I am trying to bring those student on the beginning of array whose first name is brian and rest of students should at the bottom.
Now the above code place the students on the top of the array but the rest of the students are ommited/removed. I don't want them to be removed.
I am trying to tweak what code to write in else condition.
Please help!!!
Fill $arrayStudents before the loop otherwise only matches will be collected and unshifted.
Extend example of php.net/unshift
$add = array('big');
$queue = array(
array("orange"),
array("banana"),
array("apple1"),
array("raspberry")
);
array_unshift($queue, $add);
print_r($queue);
In your case: search for keys you want to unshift, the rest goes to the standard $list = array(/list of studends/):
$list = array();
$bringToTop = array('brian', 'elvis');
foreach($data as $item) {
if (/* in in the list to bring on top*/) {
$memory[] = $item;
} else {
$list[] = $item;
}
}
foreach($memory as $item) {
array_unshift($list, $item);
}
print_r($list);
Kind regards
Add $arrayStudents[] = $row; to your else scope. Here is a simple demo to illustrate it.
When matches add the element to the result from the start of array, unmatches add them from the end of the array.
I need to print json response in php/html table, I am stuck for 4 days..
i have the json response as follows, it displays on the link http://localhost:8080/fb/?code=AQCtq-HglnDn5OZGCZAgnqiDHgL6fRHIC0054JJs6HgMmqw8h_qNDSqToe4ZxAM6kkGLDIzUaoruR0rfSlSenwRnWNv6Q6TH0Gbf6jbQ73m1uVEYnt_jrPiyawtKvj6bASITtMFC41Lly5SO25NOBRXP00RWN3uQoB3SxOe3ok3eypFZ26IRW1amNhDj3QdknvjpqsrpyhEUwK3NnHkRZmQqCKdvXywcZ-ENRxYAwN1rg4Gt0-fsdpnnKaQNx63MkXm6qEiSyIMPnZVHE7QPAJzIgdmUtK-aJD5lePpoIVJKT9P-Yy0R3ZIB2rHR5OTorx1WUOs5gHI7ANDEQnJN4mB4&state=32c7de5b745a4def2865de6684770d2d#=
array(3) {
["data"]=>
array(25) {
[0]=>
array(2) {
["id"]=>
string(15) "961716293930505"
["name"]=>
string(10) "Nena Gomez"
}
[1]=>
array(2) {
["id"]=>
string(15) "738589686317947"
["name"]=>
string(13) "Betuxx Chacon"
}
[2]=>
array(2) {
["id"]=>
string(17) "10154358290553845"
["name"]=>
string(24) "Gabriel Heredia Briseño"
}
[3]=>
array(2) {
["id"]=>
string(16) "1568587126490267"
["name"]=>
string(18) "Armando Von Thesse"
}
[4]=>
array(2) {
["id"]=>
string(17) "10211420006316586"
["name"]=>
string(11) "Any Obregon"
}
[5]=>
array(2) {
["id"]=>
string(16) "1464100830268739"
["name"]=>
string(35) "AarOnn LeOnne Raamiireez Raamiireez"
}
[6]=>
array(2) {
["id"]=>
string(16) "1210996895614354"
["name"]=>
string(23) "María José Hernández"
}
[7]=>
array(2) {
["id"]=>
string(17) "10205997740821868"
["name"]=>
string(14) "Mario Martinez"
}
[8]=>
array(2) {
["id"]=>
string(16) "1898457230384035"
["name"]=>
string(23) "Veronica Ramirez Cuevas"
}
[9]=>
array(2) {
["id"]=>
string(16) "1333307456741256"
["name"]=>
string(17) "Nicacio González"
}
[10]=>
array(2) {
["id"]=>
string(17) "10210081324343375"
["name"]=>
string(20) "Ariela Ampai Herrera"
}
[11]=>
array(2) {
["id"]=>
string(16) "1383385655027101"
["name"]=>
string(10) "Leyda Luna"
}
[12]=>
array(2) {
["id"]=>
string(17) "10154085294360936"
["name"]=>
string(17) "Ivan Azael Rivera"
}
[13]=>
array(2) {
["id"]=>
string(16) "1839478686312278"
["name"]=>
string(16) "Isamar Rodriguez"
}
[14]=>
array(2) {
["id"]=>
string(15) "954280078035568"
["name"]=>
string(32) "Seylin Mariana Brenes Peñaranda"
}
[15]=>
array(2) {
["id"]=>
string(16) "1220976504656199"
["name"]=>
string(17) "Yamili Ch Smendez"
}
[16]=>
array(2) {
["id"]=>
string(16) "1231937083552234"
["name"]=>
string(13) "Kennya Huerta"
}
[17]=>
array(2) {
["id"]=>
string(16) "1055827734543856"
["name"]=>
string(22) "Lizarazu Mario Esteban"
}
[18]=>
array(2) {
["id"]=>
string(15) "692883830880037"
["name"]=>
string(14) "Luian Suyos CA"
}
[19]=>
array(2) {
["id"]=>
string(16) "1223005904451888"
["name"]=>
string(12) "Rojas Andres"
}
[20]=>
array(2) {
["id"]=>
string(16) "1330174903721200"
["name"]=>
string(13) "Andrey Muñoz"
}
[21]=>
array(2) {
["id"]=>
string(17) "10210287624562868"
["name"]=>
string(27) "Carlos Manuel Veloz Sanchez"
}
[22]=>
array(2) {
["id"]=>
string(16) "1454728524567426"
["name"]=>
string(14) "Brandon Marín"
}
[23]=>
array(2) {
["id"]=>
string(16) "1809382102646429"
["name"]=>
string(27) "Dulce Maria Garcia Alvarado"
}
[24]=>
array(2) {
["id"]=>
string(15) "244610952637604"
["name"]=>
string(12) "Nafancy Soto"
}
}
["paging"]=>
array(2) {
["cursors"]=>
array(2) {
["before"]=>
string(20) "OTYxNzE2MjkzOTMwNTA1"
["after"]=>
string(20) "MjQ0NjEwOTUyNjM3NjA0"
}
["next"]=>
string(296) "https://graph.facebook.com/v2.8/778837615590033/likes?access_token=EAAW6655F9B8BADxO2m3VFKuNs7mEifqLGhDWEBxUtvL9jF8x8ZATLWUl0ZBR6jephQjNpWuuZCbgosbZCZAaNJLxeJ9seTxBQPneYGWMvf2I89ZAt2jOdV3rJu7iemXniCG6LiWDdUyjBl43ocEaRXPTN5qxzlPgcZD&pretty=1&summary=total_count&limit=25&after=MjQ0NjEwOTUyNjM3NjA0"
}
["summary"]=>
array(1) {
["total_count"]=>
int(28215)
}
}
likes count 28215
and my code is
<?php
session_start();
require_once __DIR__ .'/Facebook/autoload.php';
$fb = new \Facebook\Facebook([
'app_id' => '1612896019018783',
'app_secret' =>'483a369576ee496cce5780b0d5e23202' ,
'default_graph_version' => 'v2.8',
]);
$permissions = ['user_photos'];
$helper = $fb->getRedirectLoginHelper();
$accessToken=$helper->getAccessToken();
if(isset($accessToken)){
$url = "https://graph.facebook.com/v2.8/778837615590033/likes?&summary=total_count&access_token={$accessToken}";
//$url = "https://graph.facebook.com/v2.8/1205547979521647?fields=posts{likes,comments}&access_token={$accessToken}";
//$url = "https://graph.facebook.com/v2.8/1205547979521647?me?fields=id,name&access_token={$accessToken}";
$header=array("Content-type: application/json");
$ch=curl_init();
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_COOKIEJAR,'cookie.txt');
curl_setopt($ch,CURLOPT_COOKIEFILE,'cookie.txt');
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/5.0 (Windows;U;
Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
$st=curl_exec($ch);
$result=json_decode($st,TRUE);
echo "<pre>";
var_dump($result);
echo "</pre>";
$likes = $result['summary']['total_count'];
echo "likes count ". $likes;
//echo "<center>";
//echo "<img width='700' height='450' src= ><br><br>";
//echo "<img width='90' height='90' src=http://i.imgur.com/wVAJS8T.png";
//echo "</center>";
}
else
{
$loginUrl = $helper->getLoginUrl('http://localhost:8080/fb/',$permissions);
echo 'Login with FB';
}
?>
I need to display the results in results.php in table format
$data = $result['data'];
echo '<table>';
echo '<tr><td>id</td><td>name</td></tr>';
foreach ($data as $item) {
echo '<tr>';
echo '<td>' . $item['id'] . '</td>';
echo '<td>' . $item['name'] . '</td>';
echo '</tr>';
addMysql($item['id'], $item['name']);
}
echo '</table>';
function addMysql($id, $name) {
$sql = "INSERT INTO table_name (`id`, `name`) VALUE ($id, $name);";
// instance mysql driver
mysql_query($sql);
}
Your $result is in array format.So just use the table tag as below.
$result=json_decode($st,TRUE);
echo "<table>";
foreach ($result as $res) {
echo "<tr>";
echo "<td>".$res['data']['id']."</td">;
echo "<td>".$res['data']['name']."</td>";
echo "</tr">;
}
echo "</table>"
At first, Please go through my scenario, WSDL file is: https://203.196.200.42/cmspi/UCMSPAY/BusinessServices/StarterProcesses/CMS_Service.serviceagent?wsdl
Sample Request XML is:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:rev="http://www.tibco.com/schemas/CMS_Service/BusinessServices/Schemas/Rev_Input_Schema.xsd">
<soap:Header/>
<soap:Body>
<rev:reversal>
<rev:header>
<rev:req_id>01404099</rev:req_id>
<rev:msg_src>BTS</rev:msg_src>
<rev:client_code>KOSECNSE</rev:client_code>
<rev:date_post>2014-09-10T00:00:00+01:00</rev:date_post>
</rev:header>
<rev:details>
<!--Zero or more repetitions:-->
<rev:msg_id>CMS-2014062300007</rev:msg_id>
<rev:msg_id>CMS-2014062300013</rev:msg_id>
<rev:msg_id>CMS-2014062300010</rev:msg_id>
<rev:msg_id>CMS-2014062300016</rev:msg_id>
<rev:msg_id>CMS-2014042300008</rev:msg_id>
</rev:details>
</rev:reversal>
</soap:Body>
</soap:Envelope>
Now, i tried to construct the same above sample request using the PHP soapVar as follows:
$soapClient = new SoapClient('https://203.196.200.42/cmspi/UCMSPAY/BusinessServices/StarterProcesses/CMS_Service.serviceagent?wsdl',
array('trace' => 1, "exceptions"=>0, 'soap_version' => SOAP_1_1) );
$soapClient->__setLocation('https://203.196.200.42/cmspi/UCMSPAY/BusinessServices/StarterProcesses/CMS_Service.serviceagent?wsdl');
$headerRequestVar = new SoapVar(array(
'rev:req_id' => '01404099',
'rev:msg_src' => 'BTS',
'rev:client_code' => 'KOSECNSE',
'rev:date_post' => '2014-09-10T00:00:00+01:00',
), SOAP_ENC_OBJECT);
$headerRequest = new SoapVar(array('rev:header' => $headerRequestVar), SOAP_ENC_OBJECT);
$detailsRequestVar = new SoapVar(array(
'rev:msg_id' => 'CMS-2014062300007',
), SOAP_ENC_OBJECT);
$detailsRequest = new SoapVar(array('rev:details' => $detailsRequestVar), SOAP_ENC_OBJECT);
$request = new SoapVar(array('rev:reversal' => $detailsRequest, $headerRequest), SOAP_ENC_OBJECT);
$result = $soapClient->WebAPI_rev($request);
var_dump($result);
When i run the above program i am getting the following error (Var_dump response) :
object(SoapFault)#7 (10) {
["message":protected]=>
string(13) "Wrong Version"
["string":"Exception":private]=>
string(0) ""
["code":protected]=>
int(0)
["file":protected]=>
string(41) "/home/skumar/testme/kotak/soapClient3.php"
["line":protected]=>
int(37)
["trace":"Exception":private]=>
array(2) {
[0]=>
array(6) {
["file"]=>
string(41) "/home/skumar/testme/kotak/soapClient3.php"
["line"]=>
int(37)
["function"]=>
string(6) "__call"
["class"]=>
string(10) "SoapClient"
["type"]=>
string(2) "->"
["args"]=>
array(2) {
[0]=>
string(10) "WebAPI_rev"
[1]=>
array(1) {
[0]=>
object(SoapVar)#6 (2) {
["enc_type"]=>
int(301)
["enc_value"]=>
array(2) {
["rev:reversal"]=>
object(SoapVar)#5 (2) {
["enc_type"]=>
int(301)
["enc_value"]=>
array(1) {
["rev:details"]=>
object(SoapVar)#4 (2) {
["enc_type"]=>
int(301)
["enc_value"]=>
array(1) {
["rev:msg_id"]=>
string(17) "CMS-2014062300007"
}
}
}
}
[0]=>
object(SoapVar)#3 (2) {
["enc_type"]=>
int(301)
["enc_value"]=>
array(1) {
["rev:header"]=>
object(SoapVar)#2 (2) {
["enc_type"]=>
int(301)
["enc_value"]=>
array(4) {
["rev:req_id"]=>
string(8) "01404099"
["rev:msg_src"]=>
string(3) "BTS"
["rev:client_code"]=>
string(8) "KOSECNSE"
["rev:date_post"]=>
string(25) "2014-09-10T00:00:00+01:00"
}
}
}
}
}
}
}
}
}
[1]=>
array(6) {
["file"]=>
string(41) "/home/skumar/testme/kotak/soapClient3.php"
["line"]=>
int(37)
["function"]=>
string(10) "WebAPI_rev"
["class"]=>
string(10) "SoapClient"
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
object(SoapVar)#6 (2) {
["enc_type"]=>
int(301)
["enc_value"]=>
array(2) {
["rev:reversal"]=>
object(SoapVar)#5 (2) {
["enc_type"]=>
int(301)
["enc_value"]=>
array(1) {
["rev:details"]=>
object(SoapVar)#4 (2) {
["enc_type"]=>
int(301)
["enc_value"]=>
array(1) {
["rev:msg_id"]=>
string(17) "CMS-2014062300007"
}
}
}
}
[0]=>
object(SoapVar)#3 (2) {
["enc_type"]=>
int(301)
["enc_value"]=>
array(1) {
["rev:header"]=>
object(SoapVar)#2 (2) {
["enc_type"]=>
int(301)
["enc_value"]=>
array(4) {
["rev:req_id"]=>
string(8) "01404099"
["rev:msg_src"]=>
string(3) "BTS"
["rev:client_code"]=>
string(8) "KOSECNSE"
["rev:date_post"]=>
string(25) "2014-09-10T00:00:00+01:00"
}
}
}
}
}
}
}
}
}
["previous":"Exception":private]=>
NULL
["faultstring"]=>
string(13) "Wrong Version"
["faultcode"]=>
string(15) "VersionMismatch"
["faultcodens"]=>
string(41) "http://schemas.xmlsoap.org/soap/envelope/"
}
When i checked in Firebug, it is showing, status is "200 OK" , did any one know, what is happening here please. I think, if you look at the sample xml, it " < reversal > " parent has two children "< header > < details >", i passed the same in my code as shown above :
$request = new SoapVar(array('rev:reversal' => $detailsRequest, $headerRequest), SOAP_ENC_OBJECT);
Do you think this is the problem?