Skip to content

Instantly share code, notes, and snippets.

@pigeonhands
Last active August 3, 2019 18:38
Show Gist options
  • Save pigeonhands/2207b3227489559d784f to your computer and use it in GitHub Desktop.
Save pigeonhands/2207b3227489559d784f to your computer and use it in GitHub Desktop.
<?php
$data = array();
//This is an associative array with named keys as indexes
$data['Version'] = '1.0.0.0';
$data['Hash'] = '85f6ee768c10f9c09931a6ae2a94a395';
$data['Addition'] = 'Implemented multi threading, remove redundant code';
$data['Link'] = '/update/myapp.exe';
echo json_encode($data);
?>
//Created using http://json2csharp.com/
public class Update
{
public string Version { get; set; }
public string Hash { get; set; }
public string Addition { get; set; }
public string Link { get; set; }
}
//Use
// https://gist.github.com/PatPositron/10076559
// For the JSON Library
private static void Main(string[] args)
{
Update updateData;
using (var wc = new WebClient())
{
string response = wc.DownloadString("mywebsite.com/updater.php");
updateData = JsonUtil.Deserialize<Update>(response);
}
Console.WriteLine(updateData.Version);
Console.WriteLine(updateData.Hash)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment