'Accessing PHP page from C# getting different result than browser
I'm tryng a simple access to one payground PHP page returning a json string. Accessing the page from Chrome the result is ok, while accesing via WebClient or HttpClient the response text is not the same. Please, feel free to sugget what is wrong in my code and why the result is not the same as browser. Thank you in advance.
public static string GetPHP()
{
using (WebClient client = new WebClient())
{
string url = "http://twintrade.freecluster.eu/jobs/demojson.php";
string json = client.DownloadString(url);
return json;
/* PHP:
<?php
header('Content-Type: application/json');
class Fruit
{
public $name;
public $color;
function set_color($color) { $this->color = $color; }
function set_name($name) { $this->name = $name; }
function get_name() { return $this->name; }
}
$apple = new Fruit();
$apple->set_name('Apple');
$apple->set_color('Red');
$banana = new Fruit();
$banana->set_name('Banana');
$banana->set_color('Yellow');
$fruits = array($apple, $banana);
echo json_encode($fruits);
?>
Chrome returns: [{"name":"Apple","color":"Red"},{"name":"Banana","color":"Yellow"}]
json = "<html><body><script type="text/javascript" src="/aes.js" >
</script><script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}
function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f<d.length;f++)
e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),
b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("e15e41daca70a9fe7a7afd1ef557d727");
document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT;
path=/"; location.href="http://twintrade.freecluster.eu/jobs/demojson.php?i=1";</script>
<noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript>
</body></html>"
*/
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
