2

I am working of current currency rate so i did use yahoo finance link, but in curl i didn't get any reply i have tried to set content type but it doesn't work Please help me

$url=urlencode("http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ('USDUSD','USDEUR','USDGBP','USDINR','USDAED','INRINR','INREUR','INRGBP','INRAED','INRUSD')&env=store://datatables.org/alltableswithkeys"); $request = curl_init(); $timeOut = 0; curl_setopt ($request, CURLOPT_URL, $url); curl_setopt ($request, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($request, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)"); curl_setopt ($request, CURLOPT_CONNECTTIMEOUT, $timeOut); curl_setopt($request, CURLOPT_HTTPHEADER, array('Content-type: application/xml')); $response = curl_exec($request); print_r(curl_getinfo($request)); curl_close($request); 

getting response as

Array ( [url] => HTTP://http%3A%2F%2Fquery.yahooapis.com%2Fv1%2Fpublic%2Fyql%3Fq%3Dselect+%2A+from+yahoo.finance.xchange+where+pair+in+%28%27USDUSD%27%2C%27USDEUR%27%2C%27USDGBP%27%2C%27USDINR%27%2C%27USDAED%27%2C%27INRINR%27%2C%27INREUR%27%2C%27INRGBP%27%2C%27INRAED%27%2C%27INRUSD%27%29%26env%3Dstore%3A%2F%2Fdatatables.org%2Falltableswithkeys/ [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0 [namelookup_time] => 0 [connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 [redirect_url] => [primary_ip] => [certinfo] => Array ( ) [primary_port] => 0 [local_ip] => [local_port] => 0 ) 
1

1 Answer 1

3

You are urlencoding the url, which mutilates it. Try

$url = "http://query.yahooapis.com/v1/public/yql?q="; $url .= urlencode("select * from yahoo.finance.xchange where pair in ('USDUSD','USDEUR','USDGBP','USDINR','USDAED','INRINR','INREUR','INRGBP','INRAED','INRUSD')"); $url .= "&env="; $url .= urlencode("store://datatables.org/alltableswithkeys")); 

EDIT

Didn't see the second GET parameter at first, updated code.

Sign up to request clarification or add additional context in comments.

1 Comment

thank you Eugen but i made some changes in your answer like this $url="query.yahooapis.com/v1/public/yql?q=" . urlencode("select * from yahoo.finance.xchange where pair in ('USDUSD','USDEUR','USDGBP','USDINR','USDAED','INRINR','INREUR','INRGBP','INRAED','INRUSD')")."&env=store://datatables.org/alltableswithkeys"; this works for me :D

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.