Title: Returning API values from Google
Last modified: August 30, 2016

---

# Returning API values from Google

 *  Resolved [GaryKay](https://wordpress.org/support/users/garykay/)
 * (@garykay)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/returning-api-values-from-google/)
 * Hi,
 * I need to return json values from the google currency api. I have tried using
   the `wp_remote_get()` method but nothing is returned. Not really sure what I’m
   doing with it. The code snippet I’m using is from [https://currency-api.appspot.com/](https://currency-api.appspot.com/),
   the php code is
 *     ```
       $url = "https://currency-api.appspot.com/api/USD/EUR.json?amount=1.00";
   
       $result = file_get_contents($url);
       $result = json_decode($result);
   
       if ($result->success) {
   
       	echo "1 USD is worth $result->rate EUR";
       }
       ```
   
 * I would like to use this within a theme template page
 * Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Joey](https://wordpress.org/support/users/leglesslizard/)
 * (@leglesslizard)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/returning-api-values-from-google/#post-6802352)
 * Hey,
 * I copied and pasted your snippet above and it works fine. What it’s doing is 
   grabbing the content of the given url which is a string of data in json format.
   Then you use json_decode to format the data into a php object so that it is easy
   to work with and if the successful parameter is set, echo out the “rate” within
   the string.
 * This should work anywhere as long as it is inside php tags “`<?php` code goes
   here `?>`” but if you wanted to check what is being returned from the url try
   sticking `var_dump( $result );` before the if statement and seeing what is actually
   being retrieved.
 * Hope this helps! Good luck!
 *  Thread Starter [GaryKay](https://wordpress.org/support/users/garykay/)
 * (@garykay)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/returning-api-values-from-google/#post-6802354)
 * Hi Joey,
 * Thanks for the feed back. It works perfectly using localhost, as soon as I use
   it through an online server it does not work? Possibly a port issue? Same theme,
   just working locally, not too important.
 * I had found a work around using ACF.
 * Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Returning API values from Google’ is closed to new replies.

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [json](https://wordpress.org/support/topic-tag/json/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [GaryKay](https://wordpress.org/support/users/garykay/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/returning-api-values-from-google/#post-6802354)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
