Skip to content

Piero Bosio Social Web Site Personale Logo Fediverso

Social Forum federato con il resto del mondo. Non contano le istanze, contano le persone

Mastodon: toot da command line

Uncategorized
1 1 12
  • Non tutti sanno che... E' semplicissimo fare un post (toot) sul proprio profilo #mastodon con un semplice comando, ad esempio utilizzando #curl.

    Vediamo come fare.

    mastodon

    Abilitazione e creazione token

    1. Accedere, con il vostro account, al l'istanza mastodon di riferimento.
    2. Andare su Preferenze (menù a destra)
    3. Andare su Sviluppo (menù a sinistra)
    4. Fare click su Nuova applòicazione
    5. Compilare tutti i campi e concedere almeno i permessi di scrittura post.
    6. Salvare in un luogo sicuro (password manager) quanto generato.

    Comando curl di esempio

    curl -s -X POST https://mastodon.uno/api/v1/statuses \
         -H "Authorization: Bearer TOKEN_DI_ACCESSO" \
         -d "status=Ciao mondo" \
         -d "visibility=public" \
    

    Semplice Script di invio

    A questo punto possiamo farci un semplice script che prende in input, come parametro, del testo e lo invia per noi.

    cat toot.sh
    #!/bin/bash
    
    # Verifica che sia stato passato almeno un argomento
    if [ -z "$1" ]; then
      echo "Errore: devi passare il testo del toot come parametro."
      echo "Uso: $0 \"Testo del toot\""
      exit 1
    fi
    
    # Salva il parametro in una variabile
    TOOT="$1"
    
    # Esegui la richiesta POST
    curl -s -X POST https://mastodon.uno/api/v1/statuses \
         -H "Authorization: Bearer TOKEN_DI_ACCESSO" \
         -d "status=$TOOT" \
         -d "visibility=public" \
    -H "Authorization: Bearer TOKEN_DI_ACCESSO" \
    | jq '.uri'
    

    Ho inserito #jq in fondo con un filtro (che possiamo modificare a nostro piacimento), perché l'output in formato json è abbastanza prolisso

    Perché?

    A parte che è bello fare il nerd è usare #mastodon da command line, ma la cosa può essere molto utile se la usiamo in abbinata ad altre azioni/comandi. Pensiamo ad esempio ad un integraszione con #forgejo, ad esempio potremmo fare un post (tramite #webook) al termine del nostro workflow.

    Un altro esempio è il collegare l'account ad un servizio di monitoraggio come #uptimekuma in questo modo si avrà una pagina che indica ai follower lo stato dei nostri servizi.

    Oppure usarlo al termine di un nostro script che preleva i prossimi appuntamenti da un caledario ics.

    Insomma, potete integrare l'invio di un toot alla fine di un vostro script custom, il limite a questo punto è solo la fantasia!

    E voi come lo usate?

    Seguimi su mastodon: @magostinelli@mastodon.uno

    Articolo pubblicato con licenza CC BY-NC-SA

  • socialnetwork@mastodon.unoundefined socialnetwork@mastodon.uno shared this topic on
    notizie@poliverso.orgundefined notizie@poliverso.org shared this topic on

Gli ultimi otto messaggi ricevuti dalla Federazione
Post suggeriti
  • 0 Votes
    1 Posts
    5 Views
    Huh, I’m nearing 1,000 followers on here! And it’s been so much nicer than Instagram the whole time. I actually feel connected to people here, instead of just posting into an ad network void. Thank you to all of you who follow me. I really enjoy my time here with all of you around. It genuinely means a lot, and I feel lucky to have you around.#socialmedia #mastodon #mastoArt #embroidery #artist #throwbackThursday
  • You can follow hashtags on Mastodon.

    Uncategorized mastodon hashtags
    5
    0 Votes
    5 Posts
    16 Views
    @jasonbeets Here we are: Gardeners and plant friends on Mastodon#gardening#NativePlants#permaculture#gartenjournal #pflanzen #garden #garten #natur#vegetable#food#BloomScrolling#flowers#Allotment #VegetableGardening#Orchard#Obstbaum#Schrebergarten#Kleingarten#Streuobstwiese#Fleuristonfil#jardin #potager#fleur #GrowYourOwn #HomeGrown #GrownForagedHarvested #SelbstversorgerGroups:@ gardening@fedigroups.social @ allotments@fedigroups.social(without blank)
  • 0 Votes
    1 Posts
    15 Views
    I'm thrilled about the launch of @altstore's support for ActivityPub. Welcome to the fediverse! This integration will enable you to follow updates from your favorite apps and their developers right here on your fediverse timeline. You can see their server's local timeline here, to get an idea of what that looks like: https://explore.alt.store/public/localTo me, this represents an innovative and exciting new way to spread the social web to new and different kinds of apps and services. What should we make social next??And a heartfelt thank you from the @Mastodon team to AltStore for their generous donation 💞https://techcrunch.com/2025/10/07/alternative-app-store-altstore-raises-6m-connects-with-the-fediverse/#Mastodon #Fediverse #ActivityPub
  • 0 Votes
    15 Posts
    34 Views
    @_elena @Gina @NorcalGma2 @sundogplanets @sylvia @cmconseils @catsalad @skeletor @lisamelton thanks for mentioning me 🏺