Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMark MacDermot
4,488 PointsNeed Help with Task 5 on the challenge code course for Json task.
Have been stuck on this the past 2 hours! I don't know what i keep doing wrong.
<?php
function my_plugin_get_profile($my_plugin_username) {
$json_feed_url = 'http://myapi.net/' . $my_plugin_username . '.json';
$args = array( 'timeout' => 120);
$json_feed = wp_remote_get( $json_feed_url, $args );
return $json_feed;
$my_plugin_profile = json_decode( $json_feed['body'] );
return $my_plugin_profile; }
}
?>
4 Answers
Chase Marchione
155,055 PointsHi Mark,
1) You have an extra closing curly brace, so you'll want to get rid of one of those.
2) You'll want to remove the following line:
return $json_feed;
Your function currently has two return statements, and we want to keep those to one per function. Returning the $json_feed variable isn't needed in this case, so we don't need to add it to our needed return statement, either.
Hope this helps!
Mark MacDermot
4,488 Points{ is this the curly brace?
Chase Marchione
155,055 PointsYou have the right amount of those. What you have an extra of is a closing brace ('}').
Mark MacDermot
4,488 Pointsyes i did. Still no progress.
Mark MacDermot
4,488 PointsThanks for your advice! Its up and running now!
Chase Marchione
155,055 PointsNot a problem! The rule is that for every opening brace you want one closing brace: otherwise, the compiler gets confused because matching sets of opening and closing braces are used to contain things, such as function bodies.
Mark MacDermot
4,488 PointsMark MacDermot
4,488 PointsStill having a hard time with it. I did as you said. Removed the following line. Still getting it incorrect.
Chase Marchione
155,055 PointsChase Marchione
155,055 PointsHave you removed the curly brace too?