2015-04-14 29 views
0

大家卷曲和HTTP获取 - 附加功能

我很喜欢使用php,并期待找出某种东西。

我的卷曲很完美,但我需要添加一些功能,因为这只是简单的代码。

我需要帮助来添加容器/面板,你只需要写汽车编号并获得结果。

我有脚本,已经在汽车注册号码内,所以它会自动出现并显示结果。

<?php 


    $vrm = "SK54OOV"; 
    $timeStamp = time(); 
    $apiKey = "xxxxx"; (not for u) 
    $privateKey = "xxxxx";(not for u) 

    $sig = sha1($apiKey.$privateKey.$timeStamp).dechex($timeStamp); 

    $curl = curl_init(); 

    $headers = array(
    'Accept: text/xml', 
    'AUTOGURU_API_KEY: '.$apiKey, 
    'AUTOGURU_API_SIGNATURE: '.$sig 
    ); 

    curl_setopt_array($curl, array(
     CURLOPT_RETURNTRANSFER => 1, 
     CURLOPT_HTTPHEADER => $headers, 
     CURLOPT_URL => 'http://localhost/somethings?vrm='.$vrm, 
    )); 

    $resp = curl_exec($curl); 

    curl_close($curl); 

    echo $resp; 

?> 

其次的事情,是我得到的卷曲效果,但他们似乎像

SK54OOVJHMCN15204C21297921250GBRC0090001FA00BAARAL4FTI040220410316BCFDC0505OTHER02670022004122005HON1436126199HOAC22SPO4SDTM 126200HOAC22SP74SDTM 112004-09-012004-09-01HONDAACCORD I CTDI SPORTN22A1N22A1101327402204103BLUE0001-01-0100HEAVY OIL4 DOOR SALOON00001302013-05-092015-03-132013-06-140001-01-012004-09-01200400514300000000000000000197000000000000.0008072030002 AXLE RIGID BODYF£77.00£145.00HondaAccordCTDiSportSaloonDieselCarFamily45Manual5164x2FrontN22A1TransverseFront4Inline22042.2140103TurboCL, CMFA2003-03-012005-12-01RHD2670mmUnited KingdomHONDAACCORDACCORD DIESEL SALOONSportSaloonManualDiesel2.2i CTDi Sport 4dr 

如何让它们出现在HTML模板分类和优美的景色?

对不起,我是noob!

+0

什么是“美景”?换行符? – chris85

+0

使用'echo htmlentities($ resp)'从字面上看XML。 – Barmar

回答

0

您需要通过$_GET['vrm']更换$ VRM,然后你可以用一个表格创建HTML页面

<form action="yourscript.php" method="GET"> 
    <input name="vrm" type="text"/> 
    <input type="submit" value="submit"/> 
</form> 
+0

我收到此通知:Undefined变量:vrm在C:\ xampp \ htdocs \ vrmlookup.php上,第22行 发生错误。 –

+0

@NilsJoksts是否替换''http:// localhost/somethings?vrm ='。$ vrm'中的$ vrm? – jcubic

+0

作品:)谢谢 –

0

很好地看到输出,使用:

echo '<pre>' . htmlentities($resp) . '</pre>'; 

对于第一个问题,你需要研究并学习如何编写HTML表单并使用PHP处理它们。 SO不是辅导服务。

-1

由于面板,作品完美,

我加法回波 '

' . htmlentities($resp) . '
';

和响应出现

<vehicle><identifiers><vrm>SK54OOV</vrm><vin>JHMCN15204C212979</vin><gcode><id>21250</id><code>GBRC0090001FA00BAARAL4FTI040220410316BCFDC0505OTHER02670022004122005</code></gcode><thirdparty><autodata><code>HON14361</code></autodata><techdoc><code /></techdoc><cap><id>26199</id><code>HOAC22SPO4SDTM 1</code><alternatives><cap><ID>26200</ID><Code>HOAC22SP74SDTM 1</Code></cap></alternatives></cap><edi /></thirdparty></identifiers><dvladata><cherishedtransfer><marker>1</marker><date /><previousvrm /></cherishedtransfer><registrationdate><firstregistration>2004-09-01</firstregistration><firstregistrationuk>2004-09-01</firstregistrationuk></registrationdate><manufacturer>HONDA</manufacturer><model>ACCORD I CTDI SPORT</model><engine><code>N22A1</code><number>N22A11013274</number><size><cc>02204</cc></size><power><kw>103</kw></power></engine><colour><current>BLUE</current><lastcolourchangedate>0001-01-01</lastcolourchangedate><previouscolourcount>00</previouscolourcount></colour><fuel>HEAVY OIL</fuel><bodystyle>4 DOOR SALOON</bodystyle><history><export><marker>0</marker></export><import><marker>0</marker><northernireland><marker>0</marker></northernireland></import><scrap><marker>0</marker></scrap><vin><marker>1</marker></vin><previousownercount>3</previousownercount><priorregistrationuse>0</priorregistrationuse><previouskeeper><acquisitiondate>2013-05-09</acquisitiondate><disposaldate>2015-03-13</disposaldate></previouskeeper><v5cchangedate>2013-06-14</v5cchangedate><victest><date>0001-01-01</date><result /></victest></history><manufacturedate>2004-09-01</manufacturedate><manufactureyear>2004</manufactureyear><vinbuildmonth /><seatcount>005</seatcount><co2emissionsgkm>143</co2emissionsgkm><weightkg><gross>0000000</gross><unladen>000000000</unladen><fullyladen>01970</fullyladen><maxtowingbraked>00000</maxtowingbraked><maxtowingunbraked>00000</maxtowingunbraked></weightkg><powertoweightratio>0.00</powertoweightratio><noisedb><stationary>080</stationary><driveby>72</driveby><engine>03000</engine></noisedb><wheelplan>2 AXLE RIGID BODY</wheelplan><roadfundlicense><band>F</band><sixmonth>£77.00</sixmonth><twelvemonth>£145.00</twelvemonth></roadfundlicense></dvladata><enhanceddata><gcodedata><manufacturer>Honda</manufacturer><model>Accord</model><modeldescription /><specdescription>CTDi</specdescription><derivative>Sport</derivative><bodystyle>Saloon</bodystyle><fueltype>Diesel</fueltype><category>Car</category><class>Family</class><doorcount>4</doorcount><seatcount>5</seatcount><transmissiontype>Manual</transmissiontype><gearcount>5</gearcount><valvecount>16</valvecount><driveaxle>4x2</driveaxle><drivetype>Front</drivetype><engine><code>N22A1</code><alignment>Transverse</alignment><position>Front</position><cylinder><count>4</count><configuration>Inline</configuration></cylinder><size><cc>2204</cc><litre>2.2</litre></size><power><bhp>140</bhp><kw>103</kw></power><fueldelivery>Turbo</fueldelivery><emission /></engine><modelversioncode>CL, CM</modelversioncode><modelversion>FA</modelversion><specdaterange><from>2003-03-01</from><to>2005-12-01</to></specdaterange><steeringposition>RHD</steeringposition><weightkg><gross /></weightkg><wheelbasemm>2670mm</wheelbasemm><country>United Kingdom</country></gcodedata><capdata><manufacturer>HONDA</manufacturer><model>ACCORD</model><variantdescription>ACCORD DIESEL SALOON</variantdescription><derivative>Sport</derivative><bodystyle>Saloon</bodystyle><transmissiontype>Manual</transmissiontype><fueltype>Diesel</fueltype><description>2.2i CTDi Sport 4dr</description></capdata></enhanceddata></vehicle> 

如何让他们看起来像,使从卷曲输出一些定制?

http://postimg.org/image/6t9fp44p9/