Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8794493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:15:32+00:00 2026-06-13T23:15:32+00:00

the scope of my project is to pass certain values from a python script

  • 0

the scope of my project is to pass certain values from a python script to a remote php script.

i’ve a python script that generate an associatve array. For example (already JSON encoded):

{"FRONT": "19.50", "RACK": "17.63", "REAR": "21.06", "ROOM": "15.6"}

I need to pass this associative array to a remote PHP script i followed this tutorial:
http://nonstopblah.wordpress.com/2010/07/13/python-to-php-via-json/

I get 200 for HTTP Response but in the php script the POST variable seems to be empty

Here my code:

bulkData = json.dumps(temp, ensure_ascii = 'False')
# ensure_ascii is false as data is in unicode and not ascii encoding , use this if data is in any other encoding
print bulkData

print '\nHTTP Response'

headers = { "charset":"utf-8",
"Accept": "text/plain"}
conn = httplib.HTTPConnection(report_host)
postData = urllib.urlencode({'results':bulkData})
conn.request("POST", report_path, postData,headers)
response = conn.getresponse()
text = response.read()
print "Response status: ",response.status,"\n",text
conn.close()

this is the PHP script:

if( isset($_POST['results']) )
{
    $data = json_decode($_POST['results']);

    print_r($data);
}
else
{
    echo 'Nothing to listen.';
    print_r($_POST);
}

and this is the output of my python script (with the remote response):

{"FRONT": "20.44", "RACK": "18.88", "REAR": "21.25", "ROOM": "17.7"}

HTTP Response
Response status:  200 
Nothing to listen.Array
(
)

is there a smarter way to do it? What am i missing here?

Thank you in advance for your kind answers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:15:33+00:00Added an answer on June 13, 2026 at 11:15 pm

    I’d skip the urlencoded form data. Just send the raw data in the body:

    conn.request("POST", report_path, bulkData,headers)
    

    Then you can read the request body in PHP with:

    <?
    $data = json_decode(file_get_contents('php://input'));
    ?>
    

    The bulkData string is going to arrive as is in your php script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an MVC3 project where I noticed that certain fields in the
The scope of this is that we have three main projects. Some of the
Global scope allows you to use a variable in a function that was defined
I have a named scope set up in my rails application that is used
I have the following scope for finding a product that belongs to a specific
Occasionally I'll write a PHP function with a single input, an associative array containing
I'd asked a very similar question earlier , but the project scope is quickly
Interesting problem. In a project scope change, I broke one application into two applications.
How do I pass a parameter from a page's useBean in JSP to a
I need a documentation system for a PHP project and I wanted it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.