Hello Stack Exchange community,
I'm trying to make a Equifax API to get credit information (don't worry the data you see is all dummy data). I'm using their XML input. I am receiving the XML response just fine, but for some god awful reason the equifax developers decided to add some 'extra' content at the end of outside of the XML tags.
This essentially makes the xml un-parseable in php. Is there a way to strip out the extra content at the end?
Here is the XML response. Look after the closing EfxTransmit tag
<?xml version="1.0" encoding="UTF-8"?>
<EfxTransmit>
<EfxReport requestNumber="1" reportId="USConsumerCreditReport">
<USDecisionPowerExpressReports>
<USDecisionPowerExpressReport subjectType="Subject" multipleNumber="1">
<USMasterHeader>
<CustomerReferenceNumber>EFX QA</CustomerReferenceNumber>
<CustomerNumber>999KI00553</CustomerNumber>
<ECOAInquiryType>I</ECOAInquiryType>
<DateOfRequest format="MM/DD/CCYY">02/23/2017</DateOfRequest>
<EquifaxReferenceNumber>187388032</EquifaxReferenceNumber>
</USMasterHeader>
<USConsumerCreditReport subjectType="Subject" multipleNumber="1">
<USHeader>
<Request>
<CustomerReferenceNumber>EFX QA</CustomerReferenceNumber>
<CustomerNumber>999KI00553</CustomerNumber>
<ConsumerReferralCode>024</ConsumerReferralCode>
<ECOAInquiryType>I</ECOAInquiryType>
<NumberOfMonthsToCountInquiries>Last 24 Months</NumberOfMonthsToCountInquiries>
<NumberOfMonthsToCountDelinquencies>Last 6 Years, 11 Months</NumberOfMonthsToCountDelinquencies>
</Request>
<CreditFile>
<HitCode code="1" description="Hit"/>
<FileSinceDate format="MM/DD/CCYY">04/16/2003</FileSinceDate>
<DateOfLastActivity format="MM/DD/CCYY">01/24/2017</DateOfLastActivity>
<DateOfRequest format="MM/DD/CCYY">02/23/2017</DateOfRequest>
<Identityscans>
<Identityscan code="8" description="Unable to perform telephone validation due to insufficient telephone input"/>
</Identityscans>
<AddressDiscrepancyIndicator>N</AddressDiscrepancyIndicator>
<CreateCode>2</CreateCode>
<FileStatus1>016</FileStatus1>
<FileStatus2>242</FileStatus2>
<FileStatus3>004</FileStatus3>
<BureauCode>244</BureauCode>
</CreditFile>
<Subject>
<SubjectName>
<LastName>DGNNLXZ</LastName>
<FirstName>CHANITA</FirstName>
<MiddleName>S</MiddleName>
</SubjectName>
<SubjectId>
<SubjectSSN>66639074</SubjectSSN>
<DateOfBirth format="MM/DD/CCYY">08/17/1988</DateOfBirth>
</SubjectId>
</Subject>
</USHeader>
<USAddresses>
<USAddress code="CA" description="Current Address">
<ParsedStreetAddress>
<StreetNumber>4338</StreetNumber>
<StreetName>W POTOMAC</StreetName>
<StreetType>AVE</StreetType>
</ParsedStreetAddress>
<City>CHICAGO</City>
<State>IL</State>
<PostalCode>60651</PostalCode>
<DateAddressFirstReported format="MM/CCYY">07/2015</DateAddressFirstReported>
<AddressSource code="T" description="Tape"/>
<DateAddressLastReported format="MM/CCYY">02/2017</DateAddressLastReported>
</USAddress>
<USAddress code="FA" description="Former Address">
<ParsedStreetAddress>
<StreetNumber>1301</StreetNumber>
<StreetName>BRUMMEL</StreetName>
<StreetType>ST APT 8</StreetType>
</ParsedStreetAddress>
<City>EVANSTON</City>
<State>IL</State>
<PostalCode>60202</PostalCode>
<DateAddressFirstReported format="MM/CCYY">04/2015</DateAddressFirstReported>
<AddressSource code="T" description="Tape"/>
<DateAddressLastReported format="MM/CCYY">04/2015</DateAddressLastReported>
</USAddress>
<USAddress code="F2" description="Second Former Address">
<ParsedStreetAddress>
<StreetNumber>1208</StreetNumber>
<StreetName>W JEFFERSON</StreetName>
<StreetType>ST APT C</StreetType>
</ParsedStreetAddress>
<City>SPRINGFIELD</City>
<State>IL</State>
<PostalCode>62702</PostalCode>
<DateAddressFirstReported format="MM/CCYY">06/2014</DateAddressFirstReported>
<AddressSource code="T" description="Tape"/>
<DateAddressLastReported format="MM/CCYY">06/2014</DateAddressLastReported>
</USAddress>
</USAddresses>
<USEmployments>
<USEmployment code="ES" description="Last Reported Employment">
<Occupation>CORRECTION OFF</Occupation>
<Employer>MACON STATE PRISON</Employer>
</USEmployment>
</USEmployments>
<USFICO>
<FICOScore>00650</FICOScore>
<ScoreReasons>
<ScoreReason code="00038" description="Serious delinquency, and derogatory public record or collection filed" number="1"/>
<ScoreReason code="00010" description="Prop of balances to credit limits is too high on bank rev or other rev accts" number="2"/>
<ScoreReason code="00018" description="Number of accounts with delinquency" number="3"/>
<ScoreReason code="00014" description="Length of time accounts have been established" number="4"/>
</ScoreReasons>
<ScoreIndicator code="J" description="FICO Score 5 based on Equifax Data (NF)"/>
</USFICO>
<USIdentificationSSN>
<MDBSubjectSSN>666390749</MDBSubjectSSN>
<InquirySubjectSSN>666390749</InquirySubjectSSN>
<InquirySSNDateIssued>1992</InquirySSNDateIssued>
<InquirySSNStateIssued>GA</InquirySSNStateIssued>
</USIdentificationSSN>
</USConsumerCreditReport>
<USDecisionPowerExpressSegment>
<ConsumerDisclosureIndicator></ConsumerDisclosureIndicator>
<ReportTextMessage>OFFER C</ReportTextMessage>
<SSNVarianceIndicator></SSNVarianceIndicator>
<DPExpressProducts>
<DPExpressProduct number="1">
<Description>A</Description>
<ApprovalIndicator>N</ApprovalIndicator>
<Limit></Limit>
<Miscellaneous></Miscellaneous>
</DPExpressProduct>
<DPExpressProduct number="2">
<Description>B</Description>
<ApprovalIndicator>N</ApprovalIndicator>
<Limit></Limit>
<Miscellaneous></Miscellaneous>
</DPExpressProduct>
<DPExpressProduct number="3">
<Description>C</Description>
<ApprovalIndicator>Y</ApprovalIndicator>
<Limit></Limit>
<Miscellaneous></Miscellaneous>
</DPExpressProduct>
<DPExpressProduct number="4">
<Description>D</Description>
<ApprovalIndicator>N</ApprovalIndicator>
<Limit></Limit>
<Miscellaneous></Miscellaneous>
</DPExpressProduct>
</DPExpressProducts>
</USDecisionPowerExpressSegment>
</USDecisionPowerExpressReport>
</USDecisionPowerExpressReports>
<USPrintImage><![CDATA[TRANSACTION NUMBER: 187388032
BRANCH NUMBER: EFX QA
NO SUBSTANTIAL DIFFERENCE WAS FOUND BETWEEN INQUIRY ADDRESS(ES) AND
THE EXISTING CREDIT FILE ADDRESS(ES).
Product Approval Limit Misc
Indicator
C Y
OFFER C
**** Credit Report Information ****************************************
Equifax Information Services LLC
P O Box 740241, Atlanta, GA 30374-0241
800/685-1111
Name: CHANITA S DGNNLXZ Since: 04162003 SSN: 66639074
DOB/Age: 08/17/1988 Last Activity: 01242017 Report Date: 02232017
072015 4338 W POTOMAC AVE, CHICAGO IL 60651
042015 1301 BRUMMEL ST APT 8, EVANSTON IL 60202
062014 1208 W JEFFERSON ST APT C, SPRINGFIELD IL 62702
Employment information:
MACON STATE PRISON, CORRECTION OFF
Identity Scan: UNABLE TO PERFORM TELEPHONE VALIDATION DUE TO INSUFFICIENT TELEPHONE INPUT.
Customer Reference: EFX QA
ADI: NO SUBSTANTIAL DIFFERENCE WAS FOUND BETWEEN INQUIRY ADDRESS(ES) AND
THE EXISTING CREDIT FILE ADDRESS(ES).
FICO Score 5-EFX-N: 00650 00038 00010 00018 00014 Reject:
Serious delinquency, and derogatory public record or collection filed
Prop of balances to credit limits is too high on bank rev or other rev accts
Number of accounts with delinquency
Length of time accounts have been established
END OF REPORT
]]>
</USPrintImage>
</EfxReport>
</EfxTransmit>
FULLEFX QA 999KI005530241I02 1041620030124201702232017DGNNLXZ CHANITA S 66639074 08171988 0010101000000010000000000000000000000000000000000000000000000010000000000010000000100000000000000000000000000000000000000N I 2016242004244 8CA4338 W POTOMAC AVE CHICAGO IL60651 072015 T022017 FA1301 BRUMMEL ST APT 8 EVANSTON IL60202 042015 T042015 F21208 W JEFFERSON ST APT C SPRINGFIELD IL62702 062014 T062014 ESCORRECTION OFF MACON STATE PRISON CP0065000038000100001800014 J SS 666390749 6663907491992GA DP A N B N C Y D N
I'll get right to the point.
I'm trying to save data retrieved from an API using the following:
$i=0;
foreach($results->results as $product){
$products[$i]['pid'] = $product->listing_id;
$products[$i]['title'] = $product->title;
$products[$i]['url'] = $product->url;
$products[$i]['price'] = $product->price;
$products[$i]['quantity'] = $product->quantity;
$products[$i]['endtime'] = $product->ending_tsz;
$products[$i]['thumb'] = $product->results.Images[url_75x75];
Here is the JSON request:
{
"count":163,
"results":[
{
"listing_id":118973432,
"state":"active",
"user_id":27549667,
"category_id":68894752,
"title":"Funny I Love You Valentines Card - I Heart you Even More then a Nerd Loves Starwars - Adult Funny Humor Greeting Cards",
"description":"You know how much Nerds be loving the Star Wars , this Valentines day show the one you love that you love them even more then that - The perfect greeting card for that special someone!\r\n\r\nGUARANTEED CHRISTMAS DELIVERY - Place your orders by 12\/19 and get it by Christmas Eve - Upgraded Two Shipping available starting at $5, just contact us to upgrade\r\n\r\nDetails:\r\n\r\n- Outside Message: I love you even more then a nerd loves Starwars\r\n- Inside Message: Blank Inside\r\n- Size A7 (5x7)\r\n- Matching White Envelope included \r\n- Packaged in a cello sleeve for protection in transit\r\n\r\nWe will gladly ship to your recipient! Just specify a ship to address and any special message in "notes to seller" at checkout. Need a Custom Card, Magnet or keychain, we do that too!\r\n\r\nShipping:\r\nUS S&H is $2-Ships within 1 business day. Please allow 2-5 business days for delivery.\r\nIntl S&H is $4 - Ships within 1 business day - Please allow 7-10 business days for delivery.\r\n\r\nBuy MORE and SAVE on shipping! Express shipment is available to most US cities contact us for price and details.\r\n\r\nFor More Rude, crude and downright funny greeting cards, novelty gifts and prints, visit our Etsy store and browse a large selection single cards, greeting card sets, prints and more totally edgy, racy, adult, crass, lude, perverted and all things nasty!\r\nimjustsayininc.etsy.com",
"creation_tsz":1422565585,
"ending_tsz":1432929985,
"original_creation_tsz":1356746393,
"last_modified_tsz":1422565585,
"price":"4.00",
"currency_code":"USD",
"quantity":3,
"tags":[
"funny card",
"greeting card",
"novelty card",
"mature card",
"adult card",
"cards",
"funny cards",
"relationship card",
"love card",
"i love you card",
"valentines cards",
"funny valentine",
"valentines day card"
],
"category_path":[
"Paper Goods",
"Cards",
"Valentine"
],
"category_path_ids":[
69150367,
69152963,
68894752
],
"materials":[
"Papaer",
"Ink",
"Envelope"
],
"shop_section_id":12656719,
"featured_rank":null,
"state_tsz":1421921498,
"url":"https:\/\/www.etsy.com\/listing\/118973432\/funny-i-love-you-valentines-card-i-heart?utm_source=massetsy&utm_medium=api&utm_campaign=api",
"views":764,
"num_favorers":102,
"shipping_template_id":null,
"processing_min":1,
"processing_max":1,
"who_made":"i_did",
"is_supply":"false",
"when_made":"2010_2015",
"is_private":false,
"recipient":"unisex_adults",
"occasion":"valentines",
"style":null,
"non_taxable":false,
"is_customizable":true,
"is_digital":false,
"file_data":"",
"language":"en-US",
"has_variations":false,
"used_manufacturer":false,
"Images":[
{
"listing_image_id":410447372,
"hex_code":"C1AFB1",
"red":193,
"green":175,
"blue":177,
"hue":353,
"saturation":9,
"brightness":75,
"is_black_and_white":false,
"creation_tsz":1356746394,
"listing_id":118973432,
"rank":1,
"url_75x75":"https:\/\/img0.etsystatic.com\/015\/0\/7566894\/il_75x75.410447372_sjo4.jpg",
"url_170x135":"https:\/\/img0.etsystatic.com\/015\/0\/7566894\/il_170x135.410447372_sjo4.jpg",
"url_570xN":"https:\/\/img0.etsystatic.com\/015\/0\/7566894\/il_570xN.410447372_sjo4.jpg",
"url_fullxfull":"https:\/\/img0.etsystatic.com\/015\/0\/7566894\/il_fullxfull.410447372_sjo4.jpg",
"full_height":737,
"full_width":600
},
{
"listing_image_id":402927400,
"hex_code":"897761",
"red":137,
"green":119,
"blue":97,
"hue":33,
"saturation":29,
"brightness":53,
"is_black_and_white":false,
"creation_tsz":1356746394,
"listing_id":118973432,
"rank":2,
"url_75x75":"https:\/\/img0.etsystatic.com\/003\/0\/7566894\/il_75x75.402927400_e80x.jpg",
"url_170x135":"https:\/\/img0.etsystatic.com\/003\/0\/7566894\/il_170x135.402927400_e80x.jpg",
"url_570xN":"https:\/\/img0.etsystatic.com\/003\/0\/7566894\/il_570xN.402927400_e80x.jpg",
"url_fullxfull":"https:\/\/img0.etsystatic.com\/003\/0\/7566894\/il_fullxfull.402927400_e80x.jpg",
"full_height":800,
"full_width":986
},
{
"listing_image_id":402923983,
"hex_code":"C8C1C0",
"red":200,
"green":193,
"blue":192,
"hue":8,
"saturation":4,
"brightness":78,
"is_black_and_white":false,
"creation_tsz":1356746394,
"listing_id":118973432,
"rank":3,
"url_75x75":"https:\/\/img1.etsystatic.com\/005\/0\/7566894\/il_75x75.402923983_snri.jpg",
"url_170x135":"https:\/\/img1.etsystatic.com\/005\/0\/7566894\/il_170x135.402923983_snri.jpg",
"url_570xN":"https:\/\/img1.etsystatic.com\/005\/0\/7566894\/il_570xN.402923983_snri.jpg",
"url_fullxfull":"https:\/\/img1.etsystatic.com\/005\/0\/7566894\/il_fullxfull.402923983_snri.jpg",
"full_height":440,
"full_width":640
}
]
}
],
"params":{
"limit":"1",
"offset":0,
"page":null,
"shop_id":"imjustsayininc",
"keywords":null,
"sort_on":"created",
"sort_order":"down",
"min_price":null,
"max_price":null,
"color":null,
"color_accuracy":0,
"tags":null,
"category":null,
"translate_keywords":"false",
"include_private":0
},
"type":"Listing",
"pagination":{
"effective_limit":1,
"effective_offset":0,
"next_offset":1,
"effective_page":1,
"next_page":2
}
}
What I'm trying to do is pull all values from the image field where it shows an image URL (url_75x75,url_170x135,url_570xN & url_fullxfull).
I seem to be stuck only on the importing of the images. They seems to be in an array and I can't figure out how to implement pulling them like I do the rest of the content.
I've spent roughly 3 days searching, trying and failing at doing this.
I was successful when I had the Json request split up into separate requests but recently learned I could include images into one JSON request which is the method I am currently trying.
How can I do this?
I'm pretty new to PHP and I'm even newer at JSON so please be descriptive as possible and try not to overload me with complex ways I could do this, thank you.
results is an array of objects, so is Images
I didn't test it but I think something like this should be able to retrieve the first image of the first result:
$product->results[0]->Images[0]->url_75x75
In your code, this is obviously wrong:
$product->results.Images[url_75x75]
Javascript with PHP syntax mixed together? ;-)
I'm dealing with a SOAP client response for a flight booking application, I successfully got the response, See the response below:
<arzoo__response>
<Response__Depart>
<OriginDestinationOptions>
<OriginDestinationOption>
<FareDetails>
<ChargeableFares>
<ActualBaseFare>4850</ActualBaseFare>
<Tax>4267</Tax>
<STax>31</STax>
<SCharge>0</SCharge>
<TDiscount>0</TDiscount>
<TPartnerCommission>0</TPartnerCommission>
</ChargeableFares>
<NonchargeableFares>
<TCharge>0</TCharge>
<TMarkup>0</TMarkup>
<TSdiscount>0</TSdiscount>
</NonchargeableFares>
</FareDetails>
<FlightSegments>
<FlightSegment>
<AirEquipType>321</AirEquipType>
<ArrivalAirportCode>DEL</ArrivalAirportCode>
<ArrivalDateTime>2013-05-20T08:00:00</ArrivalDateTime>
<DepartureAirportCode>BOM</DepartureAirportCode>
<DepartureDateTime>2013-05-20T06:00:00</DepartureDateTime>
<FlightNumber>601</FlightNumber>
<OperatingAirlineCode>AI</OperatingAirlineCode>
<OperatingAirlineFlightNumber>601</OperatingAirlineFlightNumber>
<RPH></RPH>
<StopQuantity>0</StopQuantity>
<airLineName>Air India</airLineName>
<airportTax>4267</airportTax>
<imageFileName>http://live.arzoo.com/FlightWS/image/AirIndia.gif</imageFileName>
<viaFlight></viaFlight>
<BookingClass>
<Availability>4</Availability>
<ResBookDesigCode>U</ResBookDesigCode>
</BookingClass>
<BookingClassFare>
<adultFare>4850</adultFare>
<bookingclass>U</bookingclass>
<classType>Economy</classType>
<farebasiscode>fjyS3YyUlEusLfJ4bwgPvQ==</farebasiscode>
<Rule>This fare is Refundable <br> Baggage : 25K<br>Booking Class : U|Re-Schedule Charges: Rs. 750 per sector + Fare difference (If any) +admin fee 500 + Service Fee of Rs. 250 Sector .|Cancellation Charges : Basic fare +Airline administration fee 500 + Service Charges 250 Per Passenger Per Sector . |</Rule>
<adultCommission>0</adultCommission>
<childCommission>0</childCommission>
<commissionOnTCharge>0</commissionOnTCharge>
</BookingClassFare>
<Discount>0</Discount>
<airportTaxChild>0</airportTaxChild>
<airportTaxInfant>0</airportTaxInfant>
<adultTaxBreakup>2800,147,1320</adultTaxBreakup>
<childTaxBreakup>0,0,0</childTaxBreakup>
<infantTaxBreakup>0,0,0</infantTaxBreakup>
<octax>0</octax>
</FlightSegment>
</FlightSegments>
<id>arzoo11</id>
<key>wtZcSVMY/gphWFSOTFWg8oKRnosq3p9wt7R4SjMB0EUK8sDjVS91GicTJzH+TWN+pNURIyTJYKOW O8yH8+0tzpA4t8aEEvzaOE6ZnTtBotFDwLtSiN0xXqMsaDl8diV51l7d9ata/3rxTgfh9d8ZSmFY VI5MVaDywdHNcjAR1vwnEycx/k1jftlsnmWWqYGnJxMnMf5NY36YIq2FtLkfcHtsd+IDEhxpxJuT v4YyS+QnEycx/k1jftlsnmWWqYGnJxMnMf5NY37ZbJ5llqmBpycTJzH+TWN+GlZsae+KA6L3dlms eLkXZFKXPvd5FAnBXnTfRGc5sz+UC8CsZNzDV2FYVI5MVaDyFiThuG7WKPhzqWDbQb1E1IqUKT5I FtF6OaCYjb6EFGhDwLtSiN0xXt7N3OmPGVH2v18OFlhFoI+A/uAfnTovYr9fDhZYRaCPgP7gH506 L2K/Xw4WWEWgj4D+4B+dOi9iv18OFlhFoI+A/uAfnTovYr9fDhZYRaCPgP7gH506L2K/Xw4WWEWg j4D+4B+dOi9iv18OFlhFoI/87KPqwdBsCm4nF4DlZwRNQ/zni8QE42g8S0GV1z3SJXaOdoTFisn9 v18OFlhFoI+ThOYsjNAbXEP854vEBONoPEtBldc90iVD/OeLxATjaAwTg0ygCEBmEgnKEhG4Md1D /OeLxATjaDxLQZXXPdIlQ/zni8QE42jXGTnbB/ydvR4daAuN34kWYVhUjkxVoPJtRWbi6bZrXL9f DhZYRaCPgP7gH506L2K/Xw4WWEWgj4D+4B+dOi9iv18OFlhFoI8KriAmVoEyR3OpYNtBvUTUp1Mf I240+obPusGaAOeuxg==</key>
</OriginDestinationOption>
</OriginDestinationOptions>
</Response__Depart>
</arzoo__response>
Now i have to display them as :
Base Price: 4850
Tax: 31
STax: 31
SCharge: 0
TDiscount: 0
TPartnerCommission: 0
.....................
Arrival Airport Code: DEL
.....................
I tried several methods using foreach():
$result = $client->__call('getAvailability',array($test));
$xml = simplexml_load_string($result);
foreach($xml->OriginDestinationOption as $od){
foreach($od->FareDetails as $fd){
foreach($fd->ChargeableFares as $cf){
echo $cf->ActualBaseFare;
}
}
}
but never sot it out. Can any one please help me out on this ?
Your help must appreciated. Thanks in advance
You are trying to access OriginDestinationOption as though it is a direct child of the XML response, but the structure is actually like this:
<arzoo__response>
<Response__Depart>
<OriginDestinationOptions>
<OriginDestinationOption>
So, since your $xml will represent the arzoo__response element, you need to traverse the other elements in between:
foreach($xml->Response__Depart->OriginDestinationOptions->OriginDestinationOption as $od)