Receiving photos from Human.io / using Human.io with PHP

14 views
Skip to first unread message

Jon

unread,
Sep 27, 2012, 1:11:33 PM9/27/12
to humanio...@googlegroups.com
Hi,
 
I have 2 questions and would really appreciate some help!
 
Q1) I've been experimenting with the "Take a picture of Mountain View" example. I'd like to write an app similar to this that would ask users to take a photo and then display it instantly on a web page. The example app returns a text string containing the URL where the image is saved on Human.io's servers. How can I 'grab' this image and save a copy on my own server?
 
Sorry if this is a really dumb question, I am also new to Python so have a lot to learn!
 
Q2) I'd like to call Human.io Python scripts from within a PHP script, then return the results to PHP. For example, say I wanted to run a survey using Human.io, targeted at people in a certain (user defined) place. I'm thinking of something like the following:
1. Collect form data (such as co-ordinates of the place I want to survey)
2. Launch Python script to complete the task in Human.io, passing the variables I just collected
3. Return the responses from Python back to PHP and save in a MySQL database
4. Have a page written in PHP to view/analyse the results
 
How do I run a Python script from within PHP, and return the results back to PHP? Or should I be skipping the PHP altogether and doing everything in Python?
Thanks for any help.

Lawrence Kesteloot

unread,
Sep 27, 2012, 1:22:37 PM9/27/12
to humanio...@googlegroups.com
Hi,

A1) You're free to copy the image to your own server, but you're also
free to just use our image server. You can make a web page that just
references our server directly (i.e., use the URL unmodified). If
you're asking how to make a web page that has photos, then wait a few
days and we'll release a new feature that lets you post photos to
Tumblr automatically from your script.

A2) We have a PHP API:
http://blog.human.io/2012/09/11/php-api-now-available/ It's
experimental, but I recommend you just do everything in PHP and skip
Python.

Lawrence
> --
> You received this message because you are subscribed to the Google Groups
> "humanio-discuss" group.
> To post to this group, send email to humanio...@googlegroups.com.
> To unsubscribe from this group, send email to
> humanio-discu...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/humanio-discuss/-/saOIJcyq5W8J.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Nick Nguyen

unread,
Sep 27, 2012, 2:33:32 PM9/27/12
to humanio...@googlegroups.com
Also, for more general tips on how to deal with files and URLs, look at StringIO and urllib2.  Here's a snippet that will help you get started:

    # open file
    f = urllib2.urlopen(photo_url)
    # create in memory file
    local_file = StringIO(f.read())

The local_file object you can treat just like a file on disk.
Reply all
Reply to author
Forward
0 new messages