Why do you use curl in the first place?
Python has extensive libraries for Facebook and includes libraries for web requests; calling another program and receiving output is not required.
Nevertheless,
First from a Python document
data can be a string indicating additional data to send to the server, or None if such data is not required. Currently, HTTP requests are only those that use data; The HTTP request will be POST instead of GET when a data parameter is provided . data should be a buffer in the standard format application/x-www-form-urlencoded . The urllib.urlencode () function accepts a mapping or sequence of 2 sets and returns a string in this format. The urllib2 module sends HTTP / 1.1 requests with a connection: the private header is enabled.
So,
import urllib2, urllib parameters = {} parameters['token'] = 'sdfsdb23424' parameters['message'] = 'Hello world' target = 'http://www.target.net/work' parameters = urllib.urlencode(parameters) handler = urllib2.urlopen(target, parameters) while True: if handler.code < 400: print 'done'
Umur Kontacı
source share