Blynk Cloud to Website (solved)

I am new to blynk,.but have used cloud with success.
I have a website where I get Particle cloud data into a webpage. Very simple, lots of examples.

Now am trying to get data into the website page to display variables.
The website is coded in PHP or javascript but I can learn other methods if required.
I must be missing something fundamental?

There is already data in the Blynk cloud and if I place this url in my Browser it works (the return value is shown in the browser page:**********&dataStreamId=3

So, how do I put code (PHP, javascript, etc) in a website page to get that return into a PHP or Javascript variable?

This cannot be that difficult. A 20 line example would probably get me started

Or a link to examples of getting data into a website page.

Any suggestions or help would be much appreciated.

Solved I found this html / javascript code to work with or without the ny3. in the url.

       <title>Weather Station</title>
     var request = new XMLHttpRequest();'GET', '*********&dataStreamId=3');
      //'GET', '*********&dataStreamId=3');
     request.onreadystatechange = function () {
      if (this.readyState === 4) {
         //  console.log('Status:', this.status);   // not needed
         //  console.log('Headers:', this.getAllResponseHeaders());  // not needed
         //  console.log('Body:', this.responseText);     //  This is dataStreamid 3 value
         //  alert(this.responseText);      // Just show the value in an alert
         // document write puts text onto the webpage.  
         document.write(" <h4>Weather Station<br>Development </h4>Wind Gusts: " + this.responseText + "  <br> "); 

I know nothing about PHP and web design, but the API documentation for the Legacy API had the option to show methods in various languages.
The link is here:
By default is shows the RAW request. However, you can change that to PHP and it shows a code snippet…

Obviously, you’ll need to change the syntax of the actual URL to the one, but maybe this will get you started?

Also, you need to read this:


You need to put the full URL of the Blynk server that hosts your project into the API call, otherwise the machine hosting your website may resolve to the wrong geographic cloud server and you will get an Invalid Auth Token error.


1 Like

The javascript example is not recommended because it shows the token in the webpage source

Here is a php Curl example which runs on the server and will not display the token in the webpage
NOTE: This did not run in my local server. returned this message:
‘SSL certificate problem: unable to get local issuer certificate’
This seem to suggest the website you are creating a page in must have SSL
The code works in my actual website - It uses SSL .

For the code to work with a webpage NOT using SSL just use the url with http:// …
instead of https://

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “***********&v0&v1&v2&v3&v4&v5&v6&v7&v8&v9&v10”);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
$response = curl_exec($ch);
echo "
All variables from Weather Station
echo "
Error Return

Hope this helps someone else

1 Like

Thanks for input. I was trying the Curl solution on my local server which did not like the https:// in the url and I was not looking at the Curl errors. Duh! Thanks again!

See my solutions in original post and in my reply to original post

Glad you managed to get it working, and thanks for the follow-up.