Ubidots Community

Problems php ubidots

Hi!

I have the next problem.

Notice: Undefined index: token in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\ServerBridge.php on line 32
Notice: Undefined index: id in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 16
Notice: Undefined index: name in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 17
Notice: Undefined index: url in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 18
Notice: Undefined index: last_activity in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 19
Notice: Undefined index: tags in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 20
Notice: Undefined index: description in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 2
Notice: Undefined index: created_at in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 22
Notice: Undefined index: icon in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 23
Notice: Undefined index: unit in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 24
Notice: Undefined index: datasource in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 25
Notice: Undefined index: properties in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 26
Notice: Undefined index: values_url in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 27
Notice: Undefined index: last_value in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 28
Notice: Undefined variable: my_variable in C:\xampp\htdocs\HialinaV2A\av.php on line 9
Fatal error: Call to a member function save_value() on null in C:\xampp\htdocs\HialinaV2A\av.php on line 9

And this is mi code:

<?php
require 'vendor/autoload.php';
$api = new Ubidots\ApiClient($apikey="xxxxxx");
$my_specific_variable = $api->get_variable('xxxxx');
$new_value = $my_variable->save_value( array('value'=>10) );
?>

I can send value with the same API and varible but with javascript code, The issue is with PHP.

Hi there, did you read the console output messages? At this line:

Notice: Undefined variable: my_variable in C:\xampp\htdocs\HialinaV2A\av.php on line 9

The message is suggesting that you have a non-defined variable and so an exception error is raised, just define properly your variable.

All the best

Hi Jose Garcia!!

Thanks for response.

I change the mistake but some errors continue. The errors are:

Notice : Undefined index: token in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\ServerBridge.php on line 32

Notice : Undefined index: id in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 16

Notice : Undefined index: name in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 17

Notice : Undefined index: url in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 18

Notice : Undefined index: last_activity in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 19

Notice : Undefined index: tags in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 20

Notice : Undefined index: description in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 21

Notice : Undefined index: created_at in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 22

Notice : Undefined index: icon in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 23

Notice : Undefined index: unit in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 24

Notice : Undefined index: datasource in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 25

Notice : Undefined index: properties in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 26

Notice : Undefined index: values_url in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 27

Notice : Undefined index: last_value in C:\xampp\htdocs\HialinaV2A\vendor\ubidots\ubidots\src\Ubidots\Variable.php on line 28

I did test with the same token and varible but with js code, and I can insert values without problems.