Pass longList argument to TECDOC webservice from php - php

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

Related

how to get a specific value from api curl php

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']);
}

Grab specific node from array that's buried within others

I'm getting data from an API using the following:
function get_web_page($url) {
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_ENCODING => "", // handle compressed
CURLOPT_USERAGENT => "Space-X", // name of client
CURLOPT_AUTOREFERER => true, // set referrer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // time-out on connect
CURLOPT_TIMEOUT => 120, // time-out on response
);
$ch = curl_init($url);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
curl_close($ch);
return $content;
}
$response = get_web_page("https://api.spacexdata.com/v3/launches/latest?pretty=true");
$resArr = array();
$resArr = json_decode($response);
echo "<pre>"; print_r($resArr); echo "</pre>";
With the returned data I'm trying to get specific elements from the array. For example the flight number is easy enough by using:
$flight_number = $resArr->flight_number;
echo $flight_number;
But doing something like the following to get the serial number doesn't work. Where am I going wrong?
$core_serial = $resArr->rocket->first_stage->cores->0->core_serial;
echo $core_serial;
Here's the output of the API:
stdClass Object
(
[flight_number] => 78
[mission_name] => CRS-17
[mission_id] => Array
(
[0] => EE86F74
)
[launch_year] => 2019
[launch_date_unix] => 1556952480
[launch_date_utc] => 2019-05-04T06:48:00.000Z
[launch_date_local] => 2019-05-04T02:48:00-04:00
[is_tentative] =>
[tentative_max_precision] => hour
[tbd] =>
[launch_window] => 0
[rocket] => stdClass Object
(
[rocket_id] => falcon9
[rocket_name] => Falcon 9
[rocket_type] => FT
[first_stage] => stdClass Object
(
[cores] => Array
(
[0] => stdClass Object
(
[core_serial] => B1056
[flight] => 0
[block] => 5
[gridfins] => 1
[legs] => 1
[reused] =>
[land_success] => 1
[landing_intent] => 1
[landing_type] => ASDS
[landing_vehicle] => OCISLY
)
)
)
[second_stage] => stdClass Object
(
[block] => 5
[payloads] => Array
(
[0] => stdClass Object
(
[payload_id] => CRS-17
[norad_id] => Array
(
[0] => 44222
)
[cap_serial] => C113
[reused] => 1
[customers] => Array
(
[0] => NASA (CRS)
)
[nationality] => United States
[manufacturer] => SpaceX
[payload_type] => Dragon 1.1
[payload_mass_kg] => 2482
[payload_mass_lbs] => 5472
[orbit] => ISS
[orbit_params] => stdClass Object
(
[reference_system] => geocentric
[regime] => low-earth
[longitude] =>
[semi_major_axis_km] => 6787.07
[eccentricity] => 0.0001369
[periapsis_km] => 408.006
[apoapsis_km] => 409.865
[inclination_deg] => 51.6417
[period_min] => 92.743
[lifespan_years] =>
[epoch] => 2019-05-14T13:40:22.000Z
[mean_motion] => 15.5267006
[raan] => 168.2377
[arg_of_pericenter] => 352.6849
[mean_anomaly] => 127.392
)
[mass_returned_kg] =>
[mass_returned_lbs] =>
[flight_time_sec] =>
[cargo_manifest] => https://www.nasa.gov/sites/default/files/atoms/files/spacex_crs-17_mission_overview.pdf
)
)
)
[fairings] =>
)
[ships] => Array
(
[0] => OCISLY
[1] => Hollywood
[2] => GOQUEST
)
[telemetry] => stdClass Object
(
[flight_club] => https://www.flightclub.io/result/2d?code=CR17
)
[launch_site] => stdClass Object
(
[site_id] => ccafs_slc_40
[site_name] => CCAFS SLC 40
[site_name_long] => Cape Canaveral Air Force Station Space Launch Complex 40
)
[launch_success] => 1
[links] => stdClass Object
(
[mission_patch] => https://images2.imgbox.com/12/47/6uim8L1a_o.png
[mission_patch_small] => https://images2.imgbox.com/fc/58/9UErD3ut_o.png
[reddit_campaign] => https://new.reddit.com/r/spacex/comments/bd2l28/crs17_launch_campaign_thread/
[reddit_launch] => https://www.reddit.com/r/spacex/comments/bjsn0v/rspacex_crs17_official_launch_discussion_updates
[reddit_recovery] => https://www.reddit.com/r/spacex/comments/bjy7p5/rspacex_crs17_recovery_discussion_updates_thread
[reddit_media] => https://www.reddit.com/r/spacex/comments/bkc4d5/rspacex_crs17_media_thread_videos_images_gifs
[presskit] => https://www.spacex.com/sites/spacex/files/crs-17_press_kit.pdf
[article_link] => https://spaceflightnow.com/2019/05/04/spacex-launches-space-station-resupply-mission-lands-rocket-on-drone-ship/
[wikipedia] => https://en.wikipedia.org/wiki/SpaceX_CRS-17
[video_link] => https://youtu.be/AQFhX5TvP0M
[youtube_id] => AQFhX5TvP0M
[flickr_images] => Array
(
[0] => https://live.staticflickr.com/65535/46856594435_206c773b5a_o.jpg
[1] => https://live.staticflickr.com/65535/47720639872_284e49381d_o.jpg
[2] => https://live.staticflickr.com/65535/46856594755_88f1b22e50_o.jpg
[3] => https://live.staticflickr.com/65535/47720639542_1b7c1a71b0_o.jpg
[4] => https://live.staticflickr.com/65535/47720639732_e04b2a9ed7_o.jpg
[5] => https://live.staticflickr.com/65535/32829382467_087d024428_o.jpg
)
)
[details] => SpaceX's 17th Commercial Resupply Services mission for NASA out of a total of 20 contracted flights, this mission brings essential supplies to the International Space Station using SpaceX's reusable Dragon 1 spacecraft. The external payloads for this mission include Orbital Carbon Observatory 3 and Space Test Program-Houston 6. The Falcon 9 launches from SLC-40 at Cape Canaveral AFS. The booster was expected to land at LZ-1, however, due to the ongoing investigation and clean-up following the Crew Dragon testing incident, it is likely to land on OCISLY instead.
[upcoming] =>
[static_fire_date_utc] => 2019-04-27T07:23:00.000Z
[static_fire_date_unix] => 1556349780
[timeline] => stdClass Object
(
[webcast_liftoff] => 900
[go_for_prop_loading] => -2280
[rp1_loading] => -2100
[stage1_lox_loading] => -2100
[stage2_lox_loading] => -960
[engine_chill] => -420
[prelaunch_checks] => -60
[propellant_pressurization] => -60
[go_for_launch] => -45
[ignition] => -3
[liftoff] => 0
[maxq] => 72
[meco] => 137
[stage_sep] => 141
[second_stage_ignition] => 148
[first_stage_boostback_burn] => 154
[first_stage_entry_burn] => 399
[first_stage_landing] => 507
[seco-1] => 519
[dragon_separation] => 578
[dragon_solar_deploy] => 728
[dragon_bay_door_deploy] => 8340
)
)
You have an array down there in the mix, specifically cores
See how it is annotated on the dump [cores] => Array rather than, for example [rocket] => stdClass Object
so
$core_serial = $resArr->rocket->first_stage->cores[0]->core_serial;

Getting wrong number of results in youtube API php

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?

print encoded or decoded json in readable format

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?

XML Data - How To Access

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;
}
}

Categories