2014-06-24 3 views
0
<?php error_reporting(0); 
    $currency_code = $_GET['currency_code'];  
    $currency_opt = strtoupper($currency_code)."INR"; 
    $jsn_response = file_get_contents('http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20%28%22' .$currency_opt. '%22%29&format=json&env=store://datatables.org/alltableswithkeys&callback='); 

    $currencyrate_arr = json_decode($jsn_response, true); 

    $currency_rate = $currencyrate_arr['query']['results']['rate']['Rate']; 
    //var_dump($currency_rate); 
    if($currency_rate > 0){  
     echo $currency_text = $currency_rate; 
    } 
    else{  
     echo $currency_text = "SORRY! ERROR..";  
    } 
?> 

통화가 잘되었지만 통화 변환을 위해이 코드를 사용하는 중에 오류가 발생했습니다.yahoo의 통화 변환기를 구현하는 중 오류가 발생했습니다.

+0

것은 ... 당신이 무엇을 얻을 오류 – TiMESPLiNTER

+0

1 GBP = 경고를 알려에 http : // 래퍼하여 서버 구성에서 사용할 수 없습니다 allow_url_fopen을 = 0 /homeb/home/arpan/www/donate/cur_conv.php 온라인 6 경고 : file_get_contents (http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo. finance.xchange % 20where % 20pair % 20in % 20 % 28 % 22GBPINR % 22 % 29 & format = json & env = store : //datatables.org/alltableswithkeys&callback=) : 스트림을 열지 못했습니다./homeb/home에서 적절한 래퍼를 찾을 수 없습니다. /arpan/www/donate/cur_conv.php on line 6 죄송합니다! 오류 .. INR – user3627349

답변

0

스크립트가 저에게 효과적이며 올바른 결과를 제공합니다.

오류가 발생하는 경우 서버 구성 또는 API 제한으로 인해 발생합니다.

당신은 YQL에서 https://developer.yahoo.com/yql/faq/

속도 제한이 당신의 인증을 기반으로 확인할 수 있습니다. 당신은 IP 기반 인증을 사용하는 경우, 당신은 제한됩니다 2,000 통화/시간/공공 YQL 웹 서비스 URL에 IP (/ V1/공공/*) 당신이 시간당 2000 호출을 초과해야하는 경우

제한, 자세한 내용은 위의 링크를 참조하십시오.

PS : 디버깅 할 경우이 설정 :

error_reporting(E_ALL); 
ini_set('display_errors', 1); 

편집 : allow_url_fopen이 비활성화되어 있기 때문에, 외부의 URL에 file_get_contents을 사용할 수 없지만 여전히 CURL을 사용할 수 있습니다.

그래서 바로 교체 file_get_contents과 : file_get_contents() :

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, 'http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20%28%22' .$currency_opt. '%22%29&format=json&env=store://datatables.org/alltableswithkeys&callback='); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
$jsn_response = curl_exec($ch); 
curl_close($ch); 
+0

1 GBP = 경고 : file_get_contents() : 서버 구성에서 /homeb/home/arpan/www/donate/cur_conv.php의 allow_url_fopen = 0에 의해 http : // wrapper가 사용 중지되었습니다. 경고 : file_get_contents (http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20%28%22GBPINR%22%29&format=json&env= store : //datatables.org/alltableswithkeys&callback=) : 스트림을 열지 못했습니다 : /homeb/home/arpan/www/donate/cur_conv.php 온라인 6에 적합한 래퍼가 없습니다. 죄송합니다! 오류 .. INR – user3627349

+0

응답을 추가했습니다. upvote 및 허용 내 대답을 표시하는 것을 잊지 마세요 :) –

관련 문제