Python Forum
GET Request and JSON response
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GET Request and JSON response
#1
Good morning

I'm trying to use Python to connect to a MySQL Database, so I'm trying to use a GET request and a PHP script.

The code I have so far is:
import requests
import json

print 'Hello, World'


url = 'https://www.thebar.inthepub.co.uk/resttest.php'

response = requests.get(url)

dict = response.json()

print (dict)
This then links to a file with the following:
<?php

  echo '<p>test</p>';

$myObj->name = "John";
$myObj->age = 30;
$myObj->city = "New York";

$myJSON = json_encode($myObj);

echo $myJSON;


?>
But when I run it, I get an error, 'No JSON Object could be decoded'. Any ideas why? Is it my code, or is there another module I need to install?

Thanks
Chris
Reply


Messages In This Thread
GET Request and JSON response - by montyonthebonty - Sep-23-2018, 10:08 AM
RE: GET Request and JSON response - by wavic - Sep-23-2018, 10:28 AM
RE: GET Request and JSON response - by wavic - Sep-23-2018, 11:32 AM
RE: GET Request and JSON response - by wavic - Sep-23-2018, 01:15 PM
RE: GET Request and JSON response - by snippsat - Sep-23-2018, 03:25 PM
RE: GET Request and JSON response - by snippsat - Sep-23-2018, 06:30 PM
RE: GET Request and JSON response - by buran - Sep-27-2018, 07:28 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Scapy, creating response for GET request. SyRex1013 4 5,186 Dec-11-2018, 07:39 AM
Last Post: SyRex1013

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020