<html>
<head>
</head>
<body class='hmmessage'><div dir='ltr'>

<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style>
<div dir="ltr">Ciao a tutti,<br>sto sviluppando un'applicazione che invia messaggi su un account twitter.<br>Mi sto servendo della libreria Python Twitter Tools (PTT) sviluppata da Mike Verdone (<a href="http://mike.verdone.ca/twitter/">http://mike.verdone.ca/twitter/</a>).<br>Il problema nasce nel momento in cui tento di inviare un messaggio contenente un'immagine da un client Unix (Centos). Se il tentativo avviene da un client Windows nessun problema.<br>Il messaggio di errore è il seguente:<br>BrokenPipeError: [Errno 32] Broken pipe<br></div><div dir="ltr">Spero tanto che mi possiate essere d'aiuto.</div><div dir="ltr">Un grazie in anticipo,</div><div dir="ltr">RKelly</div><div dir="ltr"><br>Qui di seguito allego il codice utilizzato:<br> # ============================================================================<br> # Name        : test1.py<br> # Author      : RKelly<br> # Version     : test1<br> # Date        : 08/31/2014<br> # Copyright   : (c)2014 - RKelly<br> # Description : Procedure for the publication messagges on Twitter<br> # ============================================================================<br>#!/usr/bin/env python<br>import os.path, time, datetime, json, twitter, urllib.request<br></div><div dir="ltr">def send_to_twitter(status):<br>    # Account Twitter<br>    CONSUMER_KEY = ""<br>    CONSUMER_SECRET = ""<br>    ACCESS_KEY = ""<br>    ACCESS_SECRET = ""<br>    <br>    # Sezione di autenticazione (tokens e keys)<br>    t = twitter.Twitter(auth=twitter.OAuth(ACCESS_KEY, ACCESS_SECRET, CONSUMER_KEY, CONSUMER_SECRET))<br> <br>    # Invia un tweet<br>    try:<br>        # Send a tweet with an image included (or set your banner or logo similarily)<br>        # by just reading your image from the web or a file in a string:<br>        with open(status, "rb") as imagefile:<br>            params = {"media[]": imagefile.read(), "status": "Test invio immagine..."}<br>        outcome = t.statuses.update_with_media(**params)<br>        <br>    except twitter.TwitterHTTPError as twiterror:<br>        print(u'Oops. Error updating status. Status not updated!')<br>    except UnicodeEncodeError as twiterror:<br>        print(u'Twitter module raised this error:')<br>        #print(twiterror)<br>    else:<br>        print(u'Tweet {0} created at {1}'.format(outcome[u'id_str'], outcome[u'created_at']))<br>        try:<br>            print(u'{0}'.format(status))<br>        except UnicodeEncodeError:<br>            print(u'(Tried and failed to print the tweet. Weird charmap issue?)')<br>        print<br>        return outcome<br>    return None<br> <br>def polling():<br>    send_to_twitter("image.jpg")<br> <br>#Variabile globale<br>print("waiting... press <CTRL+C> to exit.\n")<br>polling()<br></div>
                                          </div></body>
</html>