Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8788527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:10:07+00:00 2026-06-13T22:10:07+00:00

I am trying to connect with Google API currency converter. Since it returns an

  • 0

I am trying to connect with Google API currency converter. Since it returns an invalid json response, I had to change the format. But now I am stuck on how to get the information out. Any help would be greatly appreciated.
Here is my code:

$amount = '100';
$from = 'USD';
$to = 'MXN';

// Make param to be sent in API
$string = $amount.$from."=?".$to;

// Call Google API
$google_url = "http://www.google.com/ig/calculator?hl=en&q=".$string;

// Get and Store API results into a variable
$result = file_get_contents($google_url);
$result = explode('"', $result);

$fromParts = explode(' ',  $result[1]);
$toParts = explode(' ',  $result[3]);

$return = array(
    'from' => array(
        'code' => $from,
        'amount' => cleanAmount($fromParts[0])
    ),
    'to' => array(
        'code' => $to,
        'amount' => cleanAmount($toParts[0])
    )
);

$json = json_encode($return);
//echo json_encode($return);

The response I get is this:

{"from":{"code":"USD","amount":100},"to":{"code":"MXN","amount":1304.80167}}

And I am trying to extract the to->amount, but I am getting an empty result.

$obj = json_decode($json);
print $obj->{'to'};

And this is the error I am getting:

Catchable fatal error: Object of class stdClass could not be converted to string in /home/olympust/public_html/lista-traslados-mexico.php on line 101

Anyone have any idea how to get the variables from response?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:10:11+00:00Added an answer on June 13, 2026 at 10:10 pm

    You are trying to echo an object. You can do either:

    echo $obj->to->amount; // prints the value
    

    or

    print_r($obj->to); // prints the object
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make an application connect to Google Plus API, but for
I'm trying to connect to google documents (following Marco Cantu's excellent REST example) but
I am trying to connect to the RubyGems API , but when I try
I am trying to connect to Google Api through my java code and i
I am trying to connect with google via oauth V2 I make http request
I'm trying to connect to my local App Engine project using the remote API
We are trying a prototype using Google chart api. http://chart.apis.google.com/chart?chf=bg,s,000000&chxs=0,FFFFFF00,9.5&chxt=x&chs=500x300&cht=p3&chco=3072F3|FF9900|80C65A|990066&chd=t:50,5,5,40&chdl=50%C2%B0%20Apples|5%C2%B0%20Oranges|5%C2%B0%20Dates|40%C2%B0%20Strawberries&chdlp=b&chp=0.1 the problem is when
Using Python, I'm trying to connect to my AppEngine app's remote_api handler, but I
I am trying to set up my Rails application to connect to the google
I am trying to use the Bluetooth Chat sample API app that google provides

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.