| 9 | """ |
| 10 | |
| 11 | def post_cookbook(login,password,title,description,tags,code,discussion): |
| 12 | http = httplib2.Http() |
| 13 | url = 'http://login.activestate.com/signin/?next=http%3A%2F%2Fcode.activestate.com%2Frecipes%2Flangs%2Fpython%2F' |
| 14 | body = {'email': login, 'password': password} |
| 15 | headers = {'Content-type': 'application/x-www-form-urlencoded'} |
| 16 | response, content = http.request(url, 'POST', headers=headers, body=urllib.urlencode(body)) |
| 17 | |
| 18 | headers = {'Cookie': response['set-cookie'],'Content-type': 'application/x-www-form-urlencoded'} |
| 19 | #lang : 1 is for python langage |
| 20 | body = {'title': title, 'description': description,'tags':tags,'lang':1,'code' : code,'discussion':discussion} |
| 21 | url = 'http://code.activestate.com/recipes/add/' |
| 22 | response, content = http.request(url, 'POST', headers=headers,body=urllib.urlencode(body)) |
| 23 | |
| 24 | |
| 25 | if __name__ == "__main__": |