taldir

Directory service to resolve wallet mailboxes by messenger addresses
Log | Files | Refs | Submodules | README | LICENSE

taldir-validate-twitter (988B)


      1 #!/bin/bash
      2 #
      3 # IMPORTANT: Before this can be used, as the taldir service user
      4 # you need to authorize this CLI app for the taldir twitter account.
      5 # e.g.:
      6 # $ t authorize
      7 #
      8 TWITTER_USER=$(echo $1 | sed 's/@//')
      9 TWITTER_ID=$(twurl "/2/users/by/username/$TWITTER_USER" | jq -r '.data.id')
     10 CODE=$2
     11 LINK=$(taldir-cli -l -a $1 -c $2)
     12 TMPFILE="qrtmp-$CODE.png"
     13 echo "$LINK" | qrencode -o $TMPFILE
     14 MESSAGE="Follow this link to complete your Taldir registration: $LINK"
     15 echo "$MESSAGE to $TWITTER_ID"
     16 UPLOAD_RESP=$(twurl -H upload.twitter.com "/1.1/media/upload.json" -f $TMPFILE -F media -X POST)
     17 MEDIA_ID=$(echo $UPLOAD_RESP | jq -r '.media_id_string')
     18 POST_BODY=$(echo '{"event": {"type": "message_create", "message_create": {"target": {"recipient_id":"'$TWITTER_ID'"}, "message_data": {"text":"'$MESSAGE'", "attachment": {"type": "media", "media": {"id":"'$MEDIA_ID'"}}}}}}')
     19 twurl -A 'Content-type: application/json' -X POST /1.1/direct_messages/events/new.json -d "$POST_BODY"
     20 rm $TMPFILE