5

I'm having some trouble accessing a json string - Demo Link

  //PHP CODE 
$json = curl_exec($ch); 
$json = json_decode($json, true);
var_dump($json);

  // RESULTS
@{"error":"Bank account validation failed.","error_type":null,"code":400}
int(1)

Any help would be highly appreciated!

4
  • What does json returns before the json_decode call? Commented Jun 14, 2016 at 12:04
  • @ClaudioSantos - read the documentation for curl_exec(): php.net/curl_exec Commented Jun 14, 2016 at 12:04
  • Sorry, My bad. Try to echo the output of curl_exec(). What you're getting? Commented Jun 14, 2016 at 12:05
  • 4
    I imagine you're not setting CURLOPT_RETURNTRANSFER - curl_exec just returns true or false unless that's set to true, which would end up as a 1 after json_decode Commented Jun 14, 2016 at 12:08

1 Answer 1

4

curl_exec($ch)

Returns TRUE on success or FALSE on failure. However, if the CURLOPT_RETURNTRANSFER option is set, it will return the result on success, FALSE on failure.

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

2 Comments

Why the hostility? You could simply have referenced that explanation and given a short code snippet showing how to do it.
Agreed with @Yoshi. Removed the bomb at the end.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.