I'm running a curl request and it returns the below:
Array
(
[#attributes] => Array
(
[exp_cid] => 0BqO
)
[REQUEST] => Array
(
[#attributes] => Array
(
[type] => RETURN
[subtype] => CALLBUR
[EXP_ExperianRef] =>
[success] => Y
[timestamp] => Mon, 10 Feb 2014 at 10:28 AM
[id] => 0BqO
)
[MB01] => Array
(
[#attributes] => Array
(
[seq] => 01
)
[DATEOFTRANSACTION] => 20100901
[VRM] => MYREG
[VINCONFIRMATIONFLAG] => 0
[ENGINECAPACITY] => 01360
[DOORPLAN] => 14
[DATEFIRSTREGISTERED] => 20041007
[YEAROFMANUFACTURE] => 2004
[SCRAPPED] => 0
[EXPORTED] => 0
[IMPORTED] => 0
[MAKE] => PEUGEOT
[MODEL] => 307 ENVY 90
[COLOUR] => BLACK
[TRANSMISSION] => MANUAL 5 GEARS
[ENGINENUMBER] => EE
[VINSERIALNUMBER] => VF
[DOORPLANLITERAL] => 5 DOOR HATCHBACK
[MVRISMAKECODE] => L1
[MVRISMODELCODE] => BJJ
[DTPMAKECODE] => L1
[DTPMODELCODE] => 892
[TRANSMISSIONCODE] => M
[GEARS] => 5
[FUEL] => PETROL
[CO2EMISSIONS] => 155
[USEDBEFORE1STREG] => 0
[IMPORTNONEU] => 0
[UKDATEFIRSTREGISTERED] => 20041007
[MAXPERMISSIBLEMASS] => 01639
[MAXNETPOWER] => 085
[MAXTRAILERWEIGHTBRAKED] => 01000
[MAXTRAILERWEIGHTUNBRAKED] => 00620
[SOUNDLVLSTATIONARY] => 079
[SOUNDLEVELENGINESPEED] => 03938
[SOUNDLVLDRIVEBY] => 71
[SEATINGCAPACITY] => 005
[MASSINSERVICE] => 000001245
[MAKEMODEL] => PEUGEOT 307 ENVY 90
)
[MB37] => Array
(
[#attributes] => Array
(
[seq] => 01
)
[V5CDATACOUNT] => 02
[V5CDATAITEMS] => Array
(
[0] => Array
(
[DATE] => 20090825
)
[1] => Array
(
[DATE] => 20041007
)
)
)
)
)
I'm struggiling to access the return, I've tried the following but it doesn't return anything:
foreach ($xml->REQUEST->MB01 as $requestData) {
echo $requestData;
}
My other problem is depending on the vehicle reg it will return different MB blocks, is there away to return them if they are returned.
Thanks.
EDIT
This is the full code that I'm running, when it's ran all I get is < Does this mean anything?
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output[0]['REQUEST']['MB01']['DATEOFTRANSACTION'];
Cheers guys.
The return is an array, not an object. Try this :
foreach ($xml['REQUEST']['MB01'] as $requestData) {
if(is_array($requestData) {
print_r($requestData);
} else {
echo $requestData;
}
}
Related
So i was trying to get "title" and "Artist->name" from all the indexes
and i tried many times even used foreach but i am still learning curl and can only get it for the first index or a specific index here is the table
(
[data] => Array
(
[0] => Array
(
[id] => 2298089
[readable] => 1
[title] => Broken Strings
[title_short] => Broken Strings
[title_version] =>
[link] => https://www.deezer.com/track/2298089
[duration] => 250
[rank] => 749501
[explicit_lyrics] =>
[explicit_content_lyrics] => 0
[explicit_content_cover] => 0
[preview] => https://cdns-preview-1.dzcdn.net/stream/c-140e953bb38254bc8db4fe4dc97dd689-8.mp3
[md5_image] => 71698262cce4bb1c0e3d25e0707ed092
[artist] => Array
(
[id] => 4523
[name] => James Morrison
[link] => https://www.deezer.com/artist/4523
[picture] => https://api.deezer.com/artist/4523/image
[picture_small] => https://e-cdns-images.dzcdn.net/images/artist/794afe1359f598a28dc12c5496fefc2e/56x56-000000-80-0-0.jpg
[picture_medium] => https://e-cdns-images.dzcdn.net/images/artist/794afe1359f598a28dc12c5496fefc2e/250x250-000000-80-0-0.jpg
[picture_big] => https://e-cdns-images.dzcdn.net/images/artist/794afe1359f598a28dc12c5496fefc2e/500x500-000000-80-0-0.jpg
[picture_xl] => https://e-cdns-images.dzcdn.net/images/artist/794afe1359f598a28dc12c5496fefc2e/1000x1000-000000-80-0-0.jpg
[tracklist] => https://api.deezer.com/artist/4523/top?limit=50
[type] => artist
)
[album] => Array
(
[id] => 229099
[title] => Songs For You, Truths For Me (International Exclusive Bundle)
[cover] => https://api.deezer.com/album/229099/image
[cover_small] => https://e-cdns-images.dzcdn.net/images/cover/71698262cce4bb1c0e3d25e0707ed092/56x56-000000-80-0-0.jpg
[cover_medium] => https://e-cdns-images.dzcdn.net/images/cover/71698262cce4bb1c0e3d25e0707ed092/250x250-000000-80-0-0.jpg
[cover_big] => https://e-cdns-images.dzcdn.net/images/cover/71698262cce4bb1c0e3d25e0707ed092/500x500-000000-80-0-0.jpg
[cover_xl] => https://e-cdns-images.dzcdn.net/images/cover/71698262cce4bb1c0e3d25e0707ed092/1000x1000-000000-80-0-0.jpg
[md5_image] => 71698262cce4bb1c0e3d25e0707ed092
[tracklist] => https://api.deezer.com/album/229099/tracks
[type] => album
)
[type] => track
)
[1] => Array
(
[id] => 1196110412
etc.., and here is the code
$ch = curl_init();
$url = "https://api.deezer.com/search?q=broken%20strings";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$resp = curl_exec($ch);
if($e = curl_error($ch)){
echo $e;
}else{
$decoded = json_decode($resp,true);
print_r($decoded);
}
curl_close($ch);
this posts all of array
$decoded['data'] will contain an array with all your records, so you want to foreach over that:
foreach ($decoded['data'] as $record) {
On each iteration of that loop, $record will be the subarray for each individual record. So on the first iteration, $record will be:
Array(
[id] => 2298089
[readable] => 1
[title] => Broken Strings
[title_short] => Broken Strings
[title_version] =>
[link] => https://www.deezer.com/track/2298089
[duration] => 250
[rank] => 749501
...
Then you can reference each field in that array like $record['id'] or $record['link']. To "drill down" into multi-dimensional arrays, just stack consecutive [] references, like $record['album']['id'] or $record['artist']['link'].
All together:
foreach ($decoded['data'] as $record) {
printf("Title: %s\n", $record['title']);
printf("Artist: %s\n\n", $record['artist']['name']);
}
I'm taking Webhook from the FACEIT platform and I'm getting something like this
stdClass Object
(
[transaction_id] => dfba5d34-39ff-4caf-bd16-fcca57260a76
[event] => match_status_ready
[event_id] => 313d9c29-4c71-4275-adc5-8cd4111f08a6
[third_party_id] => 48b264cb-e604-405c-a24f-34a550304790
[app_id] => e3f16440-0c96-4869-9f89-78c1753a9ff5
[timestamp] => 2021-02-08T20:50:34Z
[retry_count] => 2
[version] => 1
[payload] => stdClass Object
(
[id] => 1-e383d04b-28d7-4e6d-b72a-2b8c08c8e8bf
[organizer_id] => edc12227-3b07-4c5e-9325-f223025628f3
[region] => EU
[game] => csgo
[version] => 16
[entity] => stdClass Object
(
[id] => ada458d4-34c4-47ab-84a1-1ab87626c829
[name] => ECL Division 2
[type] => hub
)
[teams] => Array
(
[0] => stdClass Object
(
[id] => d5597dd7-a5db-4602-b411-ceea05451002
[name] => team_-finn
[type] =>
[avatar] => https://assets.faceit-cdn.net/avatars/d5597dd7-a5db-4602-b411-ceea05451002_1591229111372.jpg
[leader_id] => d5597dd7-a5db-4602-b411-ceea05451002
[co_leader_id] =>
[roster] => Array
(
[0] => stdClass Object
(
[id] => 3da45845-3733-4b69-9b69-c25ea2181c4a
[nickname] => Bolitho
[avatar] => https://assets.faceit-cdn.net/avatars/3da45845-3733-4b69-9b69-c25ea2181c4a_1606685453491.jpg
[game_id] => 76561198178207317
[game_name] => C. Bolitho
[game_skill_level] => 8
[membership] =>
[anticheat_required] => 1
)
[1] => stdClass Object
(
[id] => f3b13a97-f287-4fef-9d1b-2b06e6a7c184
[nickname] => Kronos
[avatar] => https://assets.faceit-cdn.net/avatars/f3b13a97-f287-4fef-9d1b-2b06e6a7c184_1611088029728.jpg
[game_id] => 76561198064664568
[game_name] => Brawlhalla > CS
[game_skill_level] => 8
[membership] =>
[anticheat_required] => 1
)
[2] => stdClass Object
(
[id] => 02df4fd6-e47e-44e1-bf35-1e4bb54becfb
[nickname] => 180_Headshot
[avatar] => https://assets.faceit-cdn.net/avatars/02df4fd6-e47e-44e1-bf35-1e4bb54becfb_1611591673793.jpg
[game_id] => 76561198263064464
[game_name] => 76561198263064464
[game_skill_level] => 7
[membership] =>
[anticheat_required] => 1
)
[3] => stdClass Object
(
[id] => d5597dd7-a5db-4602-b411-ceea05451002
[nickname] => -finn
[avatar] => https://assets.faceit-cdn.net/avatars/d5597dd7-a5db-4602-b411-ceea05451002_1591229111372.jpg
[game_id] => 76561198284594110
[game_name] => finn
[game_skill_level] => 6
[membership] =>
[anticheat_required] => 1
)
[4] => stdClass Object
(
[id] => cd20ef72-3a7d-40df-9102-1480a591866f
[nickname] => -jonas_
[avatar] => https://assets.faceit-cdn.net/avatars/cd20ef72-3a7d-40df-9102-1480a591866f_1608470890103.jpg
[game_id] => 76561198316676876
[game_name] => j0nas21
[game_skill_level] => 5
[membership] =>
[anticheat_required] => 1
)
)
[substitutions] => 0
[substitutes] =>
)
[1] => stdClass Object
(
[id] => 5cc910f4-c71b-48ab-9733-4efc7917153c
[name] => team_LUKR-
[type] =>
[avatar] => https://assets.faceit-cdn.net/avatars/5cc910f4-c71b-48ab-9733-4efc7917153c_1611317469316.jpg
[leader_id] => 5cc910f4-c71b-48ab-9733-4efc7917153c
[co_leader_id] =>
[roster] => Array
(
[0] => stdClass Object
(
[id] => 5e0822a6-7cac-43d3-8e11-4846f09e0718
[nickname] => flunke_
[avatar] => https://assets.faceit-cdn.net/avatars/5e0822a6-7cac-43d3-8e11-4846f09e0718_1591995725180.jpg
[game_id] => 76561198060789527
[game_name] => flunke
[game_skill_level] => 7
[membership] =>
[anticheat_required] => 1
)
[1] => stdClass Object
(
[id] => 55910238-2a72-4642-aa0d-5b14870fb2d5
[nickname] => zkunky
[avatar] => https://assets.faceit-cdn.net/avatars/55910238-2a72-4642-aa0d-5b14870fb2d5_1608502753847.jpg
[game_id] => 76561198078177475
[game_name] => winch
[game_skill_level] => 5
[membership] =>
[anticheat_required] => 1
)
[2] => stdClass Object
(
[id] => 5cc910f4-c71b-48ab-9733-4efc7917153c
[nickname] => LUKR-
[avatar] => https://assets.faceit-cdn.net/avatars/5cc910f4-c71b-48ab-9733-4efc7917153c_1611317469316.jpg
[game_id] => 76561198031152268
[game_name] => lukr
[game_skill_level] => 7
[membership] =>
[anticheat_required] => 1
)
[3] => stdClass Object
(
[id] => 030ca481-1369-4393-b928-dd984dbb311c
[nickname] => tomasinio
[avatar] => https://assets.faceit-cdn.net/avatars/030ca481-1369-4393-b928-dd984dbb311c_1612353173993.jpg
[game_id] => 76561198346093855
[game_name] => tomasinio
[game_skill_level] => 5
[membership] =>
[anticheat_required] => 1
)
[4] => stdClass Object
(
[id] => 439b5a1c-dd69-49cd-bb3c-d2b47cfe7b14
[nickname] => NARUTA0
[avatar] => https://assets.faceit-cdn.net/avatars/439b5a1c-dd69-49cd-bb3c-d2b47cfe7b14_1612758081953.jpg
[game_id] => 76561198118696706
[game_name] => ² cs.money
[game_skill_level] => 8
[membership] =>
[anticheat_required] => 1
)
)
[substitutions] => 0
[substitutes] =>
)
)
[created_at] => 2021-02-08T20:47:16Z
[updated_at] => 2021-02-08T20:50:33Z
)
)
And I'm trying to update database row "Game" to 1 if the player with id is in that game
so I tried with this, I'm not getting any error but, my Game row is not updating.
<?php
include "connect_db.php";
header('Content-Type: application/json');
$request = file_get_contents('php://input');
$data = json_decode($request);
if(!empty($data)){
$req_dump = print_r($data, true);
$fp = file_put_contents('request.log', $req_dump);
if($data->event == 'match_status_ready')
{
for($i=0; $i<count($data->payload->teams); $i++){
for($j=0; $j<count($data->payload->teams[$i]->roster); $j++){
$sqlupdate[$j] = "UPDATE Korisnici SET Game='1' WHERE faceit_playerid =".$data->payload->teams[$i]->roster[$j]->id;
$conn->query($sqlupdate[$j]);
/*$message = "Tim[". $i ."] Igrač[". $j ."] - ". $data->payload->teams[$i]->roster[$j]->id ."\n";
file_put_contents('status.log', $message, FILE_APPEND);*/
}
}
$curl = curl_init("discord-webhook-url");
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode(array("content" => "!matchid ". $data->payload->id ." ".$data->event)));
echo curl_exec($curl);
}
else if($data->event == 'match_status_finished' || $data->event == 'match_status_cancelled')
{
for($i=0; $i<count($data->payload->teams); $i++){
for($j=0; $j<count($data->payload->teams[$i]->roster); $j++){
$sqlupdate = "UPDATE Korisnici SET Game='0' WHERE faceit_playerid =".$data->payload->teams[$i]->roster[$j]->id;
$conn->query($sqlupdate);
}
}
$curl = curl_init("discord-webhook-url");
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode(array("content" => "!matchid ". $data->payload->id ." ".$data->event)));
echo curl_exec($curl);
}
sleep(3);
}
else { echo "Link je prazan !"; }
?>
When I put it into log I'm getting a right thing
Tim[0] Igrač[0] - c8d41fb0-df78-4b53-a1ef-1b007f7d8f7b
Tim[0] Igrač[1] - edfeb779-89e7-485d-bbc8-64d99e3356ba
Tim[0] Igrač[2] - 13144f2a-e8b3-4469-816c-9af61caedb58
Tim[0] Igrač[3] - 268b7ac8-48dc-4bcf-995a-de00244e8cf7
Tim[0] Igrač[4] - ab056dc5-3cab-4568-9d2e-ddb405904500
Tim[1] Igrač[0] - 7196b459-4b4c-4a1b-8f46-9bb37a243c65
Tim[1] Igrač[1] - d8fe30bb-2a72-4169-9d30-1a6c82c6d0af
Tim[1] Igrač[2] - 7b4d7693-3646-4010-931c-e6f7c2790206
Tim[1] Igrač[3] - 4f789940-e122-4470-9347-82f21611132e
Tim[1] Igrač[4] - 4ccc9f0f-3536-4a1d-8386-a630cf2be337
Can anyone help me? I'm really disappointed...
Thanks sir, i finnaly got it on another way, is it allright ?
$stmt = $conn->prepare("UPDATE Korisnici SET Game='1' WHERE faceit_playerid=?");
$stmt->bind_param('s', $faceitid);
foreach ($data->payload->teams as $team){
foreach ($team->roster as $player){
/*$sqlupdate = "UPDATE Korisnici SET Game='1' WHERE faceit_playerid=" . $player->id;
$conn->query($sqlupdate);*/
$faceitid = $player->id;
$stmt->execute();
}
}
$stmt->close();
EDIT: How can i bypass too many connections with this ?
Try logging the SQL query, instead of the values. This should help you see what you're actually telling the DBMS to do. You may find that you're sending it the wrong values.
Also, instead of a couple of numerical for loops, try this:
foreach ($data->payload->teams as $team){
foreach ($team->roster as $player){
$sqlupdate = "UPDATE Korisnici SET Game='1' WHERE faceit_playerid =" . $player->id;
$conn->query($sqlupdate);
}
}
I am trying to fetch videos from youtube using below code:
$youtube_api_url = "https://www.googleapis.com/youtube/v3/search?key=".$new_key->api_key;
$youtube_api_url = $youtube_api_url."&order=relevance&type=video&maxResults=20&part=snippet&videoCategoryId=10&q=". urlencode(preg_replace('/[^a-zA-Z0-9_ %\[\]\.\(\)%&-]/s', '',$trackRecord->name));
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$youtube_api_url);
$result=curl_exec($ch);
$response = json_decode($result, true);
echo "<pre>"; print_r($response); die;
It is returning wrong number of results as below:
Array
(
[items] => Array
(
[0] => Array
(
[kind] => youtube#searchResult
[etag] => "m2yskBQFythfE4irbTIeOgYYfBU/ne5AZXpdoLtAn-mlwu4ipioOQ_I"
[id] => Array
(
[kind] => youtube#video
[videoId] => dB0ITzfbwfw
)
[snippet] => Array
(
[publishedAt] => 2017-01-23T17:31:23.000Z
[channelId] => UCdW5nPo1oyD2vLkvoYijmEg
[title] => Lihtz Kamraz "The Switch Up" Interview Part 2
[description] => In 2016, a lot of break out artists emerged and made a mark in the game. As 2017 begins, one name that you should definitely be on the lookout for is Lihtz ...
[thumbnails] => Array
(
[default] => Array
(
[url] => https://i.ytimg.com/vi/dB0ITzfbwfw/default.jpg
[width] => 120
[height] => 90
)
[medium] => Array
(
[url] => https://i.ytimg.com/vi/dB0ITzfbwfw/mqdefault.jpg
[width] => 320
[height] => 180
)
[high] => Array
(
[url] => https://i.ytimg.com/vi/dB0ITzfbwfw/hqdefault.jpg
[width] => 480
[height] => 360
)
)
[channelTitle] => HIPHOPSINCE1987TV
[liveBroadcastContent] => none
)
)
)
)
As you can see it is showing total and per page result as:
[pageInfo] => Array
(
[totalResults] => 14
[resultsPerPage] => 20
)
How can I get all results?
I am using php curl to get account and transaction data from the plaid api. I'd like to see it in a nice format so I can go about creating loops to save the information into a database. The decoded json output, when printed with print_r, is returned like this:
array ( [accounts] => Array ( [0] => Array ( [_id] => QPO8Jo8vdDHMepg41PBwckXm4KdK1yUdmXOwK [_item] => KdDjmojBERUKx3JkDd9RuxA5EvejA4SENO4AA [_user] => eJXpMzpR65FP4RYno6rzuA7OZjd9n3Hna0RYa [balance] => Array ( [available] => 1203.42 [current] => 1274.93 ) [institution_type] => fake_institution [meta] => Array ( [name] => Plaid Savings [number] => 9606 ) [subtype] => savings [type] => depository ) [1] => Array ( [_id] => nban4wnPKEtnmEpaKzbYFYQvA7D7pnCaeDBMy [_item] => KdDjmojBERUKx3JkDd9RuxA5EvejA4SENO4AA...
I'd like to get it looking like this:
Array (
[accounts] => Array (
[0] => Array (
[_id] => QPO8Jo8vdDHMepg41PBwckXm4KdK1yUdmXOwK
[_item] => KdDjmojBERUKx3JkDd9RuxA5EvejA4SENO4AA
[_user] => eJXpMzpR65FP4RYno6rzuA7OZjd9n3Hna0RYa
[balance] => Array (
[available] => 1203.42
[current] => 1274.93 )
[institution_type] => fake_institution
[meta] => Array (
[name] => Plaid Savings
[number] => 9606 )
[subtype] => savings
[type] => depository )
[1] => Array (
[_id] => nban4wnPKEtnmEpaKzbYFYQvA7D7pnCaeDBMy
[_item] => KdDjmojBERUKx3JkDd9RuxA5EvejA4SENO4AA
`
For reference, here is the code to get the response:
$data = array(
"client_id"=>"test_id",
"secret"=>"test_secret",
"access_token"=>"test_chase"
);
$string = http_build_query($data);
//initialize session
$ch=curl_init("https://tartan.plaid.com/connect/get");
//set options
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//execute session
$accountData = json_decode(curl_exec($ch), true);
print_r($accountData);
//close session
curl_close($ch);
Any thoughts other than loops?
I am working with project on TECDOC. get known about TECDOC http://webservicepilot.tecdoc.net/pegasus-2-0/ here.
So on this page http://webservicepilot.tecdoc.net/pegasus-2-0/test2/index.html
in the dropdown menu you will find functions getVehicleByIds(), getVehicleByIds2(), getVehicleByIds2StringList() and getVehicleByIdsStringList().
In above functions You will find a carIds field which have datatype as longList (for first two function) or StringList (for other two functions).
Now I while calling this function from PHP I have to pass arguments of this field in lonlList or StringList datatype which is not available in PHP and yes know generally for this task generally php array is used. But it is not working here.
here is code...
<?php
$url ="http://webservicepilot.tecdoc.net/pegasus-2-0/wsdl/TecdocToCat";
$trace = array('trace' => 1);
$client = new SoapClient($url, $trace);
$request_array = array(
'country'=>'pt',
'countryUserSetting'=>'CH',
'lang'=>'pt',
'motorCodes'=>true,
'provider'=>'452',
'vehicleTerms'=>true,
'carIds'=>1116,
'passengerCarDetails'=>true
);
echo "<pre>";
$responce = $client->getVehicleByIds($request_array);
print_r($responce);
?>
note : there are some documents provided in first link I post.
please refer InterfaceCatService.pdf for each function datatype details study.
please help me.
I can see the output like below.
stdClass Object
(
[data] => stdClass Object
(
[array] => Array
(
)
[empty] => 1
)
[status] => 200
[statusText] =>
)
Hello Again,
I have tried with CURL...by using soapclient there is issue with longlist carIds. so we can do with CURL request.
got the below output.
Array
(
[data] => Array
(
[array] => Array
(
[array] => Array
(
[0] => Array
(
[carId] => 1116
[motorCodes] => Array
(
[array] => Array
(
[array] => Array
(
[motorCode] => DZ
)
)
[empty] => false
)
[passengerCarDetails] => Array
(
[brakeSystem] => Hidráulico
[constructionType] => três volumes
[cylinder] => 4
[cylinderCapacityCcm] => 1781
[cylinderCapacityLiter] => 180
[fuelType] => Gasolina
[fuelTypeProcess] => Injecção no colector de admissão/carburador
[impulsionType] => Tracção dianteira
[manuName] => AUDI
[modelName] => 80 (89, 89Q, 8A, B3)
[motorType] => Otto
[powerHP] => 112
[powerKW] => 82
[typeName] => 1.8 E
[typeNumber] => 1116
[valves] => 2
[yearOfConstructionFrom] => 198606
[yearOfConstructionTo] => 199108
)
[vehicleDetails] => Array
(
[axisConfiguration] => Array
(
[#value] =>
[#attributes] => Array
(
[nil] => true
)
)
[carId] => 1116
[ccmTech] => 1781
[constructionType] => três volumes
[manuId] => 5
[modId] => 31
[powerHpFrom] => 112
[powerHpTo] => 112
[powerKwFrom] => 82
[powerKwTo] => 82
[tonnage] => Array
(
[#value] =>
[#attributes] => Array
(
[nil] => true
)
)
[yearOfConstrFrom] => 198606
[yearOfConstrTo] => 199108
)
[vehicleTerms] => Array
(
[carId] => 1116
[carType] => 1.8 E
[manuId] => 5
[manuName] => AUDI
[modId] => 31
[modelName] => 80 (89, 89Q, 8A, B3)
)
)
[1] => Array
(
[carId] => 1117
[motorCodes] => Array
(
[array] => Array
(
[array] => Array
(
[motorCode] => SD
)
)
[empty] => false
)
[passengerCarDetails] => Array
(
[brakeSystem] => Hidráulico
[constructionType] => três volumes
[cylinder] => 4
[cylinderCapacityCcm] => 1847
[cylinderCapacityLiter] => 180
[fuelType] => Gasolina
[fuelTypeProcess] => Injecção no colector de admissão/carburador
[impulsionType] => Tracção dianteira
[manuName] => AUDI
[modelName] => 80 (89, 89Q, 8A, B3)
[motorType] => Otto
[powerHP] => 113
[powerKW] => 83
[typeName] => 1.8
[typeNumber] => 1117
[valves] => 2
[yearOfConstructionFrom] => 198609
[yearOfConstructionTo] => 198807
)
[vehicleDetails] => Array
(
[axisConfiguration] => Array
(
[#value] =>
[#attributes] => Array
(
[nil] => true
)
)
[carId] => 1117
[ccmTech] => 1847
[constructionType] => três volumes
[manuId] => 5
[modId] => 31
[powerHpFrom] => 113
[powerHpTo] => 113
[powerKwFrom] => 83
[powerKwTo] => 83
[tonnage] => Array
(
[#value] =>
[#attributes] => Array
(
[nil] => true
)
)
[yearOfConstrFrom] => 198609
[yearOfConstrTo] => 198807
)
[vehicleTerms] => Array
(
[carId] => 1117
[carType] => 1.8
[manuId] => 5
[manuName] => AUDI
[modId] => 31
[modelName] => 80 (89, 89Q, 8A, B3)
)
)
)
)
[empty] => false
)
)
Below is the code to get response using CURL.
$soap_request = "<?xml version=\"1.0\"?>\n";
$soap_request .= '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://path- to/schemas" xmlns:urn="urn:axis.server.cat.tecdoc.net" xmlns:car="http://carselection.datatype.tocinterface.cat.tecdoc.net" xmlns:dat="http://datatype.cat.tecdoc.net" xmlns:tec="http://webservicepilot.tecdoc.net/pegasus-2-0/services/TecdocToCatWL">
<soapenv:Header/>
<soapenv:Body>
<urn:getVehicleByIds>
<urn:in0>
<car:carIds>
<dat:array>
<tec:item>1116</tec:item>
<tec:item>1117</tec:item>
</dat:array>
</car:carIds>
<car:country>pt</car:country>
<car:countryUserSetting>CH</car:countryUserSetting>
<car:lang>pt</car:lang>
<car:motorCodes>true</car:motorCodes>
<car:passengerCarDetails>true</car:passengerCarDetails>
<car:provider>292</car:provider>
<car:vehicleTerms>true</car:vehicleTerms>
</urn:in0>
</urn:getVehicleByIds>
</soapenv:Body>
</soapenv:Envelope>';
$header = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"run\"",
"Content-length: ".strlen($soap_request),
);
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, "http://webservicepilot.tecdoc.net/pegasus-2- 0/services/TecdocToCatWL?wsdl" );
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $soap_request);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header);
curl_setopt($soap_do, CURLOPT_PROXY, IF_ANY);
$result = curl_exec($soap_do);
Thanks,
Gaurang
you need to convert the array to tecdoc list type.
Its very easy though, make a stdClass object with 2 fields.
empty and array
set empty to false and array to the array of carIds like
$carIds = array(1116);
$obj = new stdClass();
$obj->empty = false;
$obj->array = $carIds;
now pass $obj in the params list of soap request
$request_array = array(
'country'=>'pt',
'countryUserSetting'=>'CH',
'lang'=>'pt',
'motorCodes'=>true,
'provider'=>'292',
'vehicleTerms'=>true,
'carIds'=> $obj,
'passengerCarDetails'=>true
);
better make a function which converts the array to above object structure, the empty flag will be set to true if array is null or empty