Jump to content




Can't unserialize


  • You cannot reply to this topic
2 replies to this topic

#1 timia2109

  • Members
  • 71 posts

Posted 19 October 2014 - 11:01 AM

Hey everyone,
I want to develop an lyrics script. I want to host a few example songs so I use a PHP script and this (http://www.computerc...erialize-to-lua) function to echo a folder list. But CC don't unserialize this table and I don't know why. Maybe anyone can help me.
I don't want to use JSON, because then you need an extra API.

If you want to test it in CC the URL is: http://timia2109.com/ccapi/lyric.php

(formated by me)
{
  [0] = {
	["get"] = "AttentionWhore.txt",
	["Artist"] = "deadmau5",
	["Song"] = "Attention Whore",
  },
  [1] = {
	["get"] = "GoldSkies.txt",
	["Artist"] = "Sander Van Doorn, Martin Garrix and DVBBS",
	["Song"]="Gold Skies",
  },
  [2] = {
	["get"] = "RedLights.txt",
	["Artist"]="Tiesto",
	["Song"]="Red Lights",
  },
  [3] = {
	["get"] = "TheSpark.txt",
	["Artist"] = "Afrojack",
	["Song"]="The Spark",
  },
  [4] = {
	["get"]="Wasted.txt",
	["Artist"]="Tiesto",
	["Song"]="Wasted (feat. Mattew Koma)",
  },
}

Real Output (copy from Chrome so also formated):
Spoiler

PHP Code:
Spoiler

Thank you and sorry for bad english,
timia2109

Edited by timia2109, 19 October 2014 - 11:05 AM.


#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 19 October 2014 - 11:28 AM

This works for me:

local webHandle = http.get("http://timia2109.com/ccapi/lyric.php")

if not webHandle then error("Unable to connect to server!") end

local myTable = textutils.unserialise(webHandle.readAll())

webHandle.close()


#3 timia2109

  • Members
  • 71 posts

Posted 19 October 2014 - 11:45 AM

Ok my error. I test it in a Emulator and there was the problem. On CC everything is working. But thanks!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users