# Obtener datos fichero JS

**URL:** <https://foros.velneo.com/t/obtener-datos-fichero-js/10005>\
**Category:** Velneo\
**Created:** [5 Noviembre, 2018 17:25 UTC](https://foros.velneo.com/t/obtener-datos-fichero-js/10005 "2018-11-05T17:25:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![overall](https://yyz1.discourse-cdn.com/flex035/user_avatar/foros.velneo.com/overall/32/5437_2.png) [@overall](https://foros.velneo.com/u/overall)\
**Post date:** [5 Noviembre, 2018 17:25 UTC](https://foros.velneo.com/t/obtener-datos-fichero-js/10005/1 "2018-11-05T17:25:15Z")

</div>

Hola,  
Necesito obtener el Handicap de Golf (un número de un decimal), desde un fichero que me ha pasado la Federación de Golf.  
El fichero es el siguiente:

> static $token = “F8E761424C6F4BC3B41A18F3BC656”;
> 
> public function getHandicap($nombre, $primerApellido, $segundoApellido, $licencia)  
> {  
> if($licencia === “”){  
> $licencia = “CB”;  
> }  
> \Log::info($nombre . ’ ’ . $primerApellido . ’ ’ . $segundoApellido . ’ ’ . $licencia);  
> $params = ‘{  
> “communication”: {  
> “response”: “string”,  
> “message”: “string”,  
> “start”: “string”,  
> “latency”: “string”,  
> “token”: "’.self::$token.‘"  
> },  
> “authenticate”: {  
> “deviceid”: “string”,  
> “send”: “string”,  
> “latency”: “string”,  
> “email”: “string”,  
> “pattern”: “string”,  
> “last”: “string”,  
> “claveActivacion”: “string”  
> },  
> “configuration”: {  
> “id”: 0,  
> “deviceid”: “string”,  
> “vuser”: {  
> “timestamp”: “string”,  
> “obligatorio”: true  
> },  
> “vnews”: {  
> “timestamp”: “string”,  
> “obligatorio”: true  
> },  
> “voffer”: {  
> “timestamp”: “string”,  
> “obligatorio”: true  
> },  
> “vspon”: {  
> “timestamp”: “string”,  
> “obligatorio”: true  
> },  
> “vcont”: {  
> “timestamp”: “string”,  
> “obligatorio”: true  
> },  
> “vstruc”: {  
> “timestamp”: “string”,  
> “obligatorio”: true  
> },  
> “vboard”: {  
> “timestamp”: “string”,  
> “obligatorio”: true  
> },  
> “vcom”: {  
> “timestamp”: “string”,  
> “obligatorio”: true  
> },  
> “vpro”: {  
> “timestamp”: “string”,  
> “obligatorio”: true  
> },  
> “vgcourse”: {  
> “timestamp”: “string”,  
> “obligatorio”: true  
> },  
> “vgame”: {  
> “timestamp”: “string”,  
> “obligatorio”: true  
> },  
> “lon”: “string”,  
> “lat”: “string”,  
> “screen”: “string”,  
> “so”: “string”,  
> “v”: “string”,  
> “active”: true,  
> “appversion”: “string”,  
> “clave”: “string”  
> },  
> “federado”: {  
> “nombre”: "’ . $nombre . ‘",  
> “apellido1”: "’ . $primerApellido . ‘",  
> “apellido2”: "’ . $segundoApellido . ‘",  
> “nombreCompleto”: “”,  
> “genre”: “”,  
> “licence”: "’ . $licencia . ‘",  
> “handicap”: “”,  
> “lastHpUpdate”: “2018-01-30T09:48:46.603Z”,  
> “hpStatus”: “string”,  
> “nivel”: “string”,  
> “categoria”: “string”,  
> “contact”: {  
> “iduser”: 0,  
> “idcontact”: “string”,  
> “licence”: “string”,  
> “nombreCompleto”: “string”,  
> “version”: “string”,  
> “handicap”: “string”,  
> “hgame”: 0,  
> “img”: “string”,  
> “genre”: “string”,  
> “points”: “string”,  
> “tee”: 0,  
> “result”: [  
> {  
> “numhole”: 0,  
> “result”: “string”,  
> “putts”: 0,  
> “fhit”: true,  
> “gir”: true,  
> “rana”: “string”,  
> “rab”: “string”,  
> “bunk”: “string”,  
> “sock”: “string”,  
> “tie”: “string”,  
> “playedBarSavedID”: 0,  
> “playedBarName”: “string”  
> }  
> ]  
> }  
> }  
> }’;  
> \Log::info($params);  
> $headers = [  
> ‘Content-Type’ =\> ‘application/json’,  
> ];
> 
> ```
> $response = $this->client->post('/Federado/ConsultaHandicap', [
> 'headers' => $headers,
> 'body' => $params,
> ]);
> $json = $response->getBody();
> $json = json_decode($json);
> return $json;
> 
> ```

Tengo una tabla donde tengo la Licencia y el Nombre, Primer Apellido y segundo Apellido. Quisiera que desde la Licencia de la tabla Velneo pudiera obtener el Handicap del Jugador (se puede obtener el handicap sobre la Licencia o sobre el nombre y apellidos del jugador)  
No sé por donde empezar.  
Necesito ayuda.  
Muchas gracias

---

<div class="post-metadata">

**Author:** ![sergioinfortic](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@sergioinfortic](https://foros.velneo.com/u/sergioinfortic)\
**Post date:** [7 Noviembre, 2018 09:09 UTC](https://foros.velneo.com/t/obtener-datos-fichero-js/10005/2 "2018-11-07T09:09:03Z")

</div>

Hola.

Supongo que la ferderación tiene un webservice para consultar el handicap.

Por lo que veo la cosa se basa en hacer un post en la url\_federacion/Federado/ConsultaHandicap  
Poniendo en el body los datos a consultar (el json params que ves en el fichero)

Mírate:

[https://doc.velneo.es/xmlhttprequest.html](https://doc.velneo.es/xmlhttprequest.html)

Hay un ejemplo “Petición POST enviando un JSON y obteniendo un JSON” , ese es tu punto de partida.

Ve mirandolo, el header es distinto y tendrás que enviar la cadena de texto con el JSON pero es muy parecido a lo que quieres hacer.

---

<div class="post-metadata">

**Author:** ![overall](https://yyz1.discourse-cdn.com/flex035/user_avatar/foros.velneo.com/overall/32/5437_2.png) [@overall](https://foros.velneo.com/u/overall)\
**Post date:** [7 Noviembre, 2018 09:53 UTC](https://foros.velneo.com/t/obtener-datos-fichero-js/10005/3 "2018-11-07T09:53:41Z")

</div>

Muchas gracias @sergioinfortic,  
Mi conocimiento para este desarrollo es muy limitado. Agradezco tu respuesta.  
Si tú, o alguien del foro puede hacerme esta integración, que se ponga en contacto conmigo a [overall@overall-bcn.com](mailto:overall@overall-bcn.com)  
Saludos y gracias
