PHP OpenWeather

Alright so I am having some troubles understanding how to use the open weather API. I have tried using it as

<?php
    $request = file_get_contents('http://api.openweathermap.org/data/2.5/forecast/city?id=myidblablabla'); //example ID

    $jsonPHP  = json_decode($request);

    echo $jsonPHP->city;

?>

But I get an error saying

Catchable fatal error: Object of class stdClass could not be converted to string in

Now there is 1 more question that I have to ask, how do I get certains City Temperature, humidity etc? From the code I received I get only Moscow

To simplify it, you can also transform the json into array instead.

$jsonPHP  = json_decode($request,true);

Now let's discuss it briefly. According to the documentation (http://openweathermap.org/current),

Note also that I've never used this API before. I'm just trying to help here.

If you hit api.openweathermap.org/data/2.5/weather?lat=35&lon=139

It responds as

{"coord":{"lon":139,"lat":35},
"sys":{"country":"JP","sunrise":1369769524,"sunset":1369821049},
"weather":[{"id":804,"main":"clouds","description":"overcast clouds","icon":"04n"}],
"main":{"temp":289.5,"humidity":89,"pressure":1013,"temp_min":287.04,"temp_max":292.04},
"wind":{"speed":7.31,"deg":187.002},
"rain":{"3h":0},
"clouds":{"all":92},
"dt":1369824698,
"id":1851632,
"name":"Shuzenji",
"cod":200}

Now assuming you want to take the weather and humidity , it just :

weather :

echo $jsonPHP["weather"][0]["id"];

humidity:

echo $jsonPHP["main"]["humidity"];

Note also that, If you hit http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139 and get the responds as

{"cod":401, "message": "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."}

For the case, they've explained here :

http://openweathermap.org/faq#error401 which is :

Q: API calls return an error 401

A: Starting from 9 October 2015 our API requires a valid APPID for access. Note that this does not mean that our API is subscription-only now - please take a minute to register a free account to receive a key.

We are sorry for inconvenience but this is a necessary measure that will help us deliver our services to you faster and more reliably.

For FOSS developers: we welcome free and open source software and are willing to help you. If you want to use OWM data in your free software application please register an API key and file a ticket describing your application and API key registered. OWM will review your request lift access limits for your key if used in open source application.