2017-05-03 1 views
0

ソーシャルメディア用の共有ボタンを追加したいと思います。私はスラックのワークフローボタンが機能しているのですが、メッセージペイロードを受け取った人は、受け取っているものを共有できるようにしたいと思います。これまでに私が得たことがここにあります。Python 2.7のSlack APIペイロードにTwitter共有ボタンを追加する方法はありますか?

def post_summary_to_slack(self): 
    data = str(
     {'text': self.summary_printout, 
      'attachments': [ 
       { 
        "fallback": "Was this a good use of time and money?", 
        "title": "Was this a good use of time and money?", 
        "callback_id": "meetings_survey", 
        "color": "#800080", 
        "attachment_type": "default", 
        "actions": [ 
         { 
          "name": "yes", 
          "text": "Yes", 
          "type": "button", 
          "value": "yes" 
         }, 
         { 
          "name": "no", 
          "text": "No", 
          "type": "button", 
          "value": "no" 
         }, 
         { 
          "name": "maybe", 
          "text": "I'm Not Sure", 
          "type": "button", 
          "value": "maybe" 
         }, 
         /* maybe here:*/ 
         { 
          "name": "twitter", 
          "text": "Tweet", 
          "type": "button", 
          "value": "Here are the results from the latest analysis" 
         } 
        ] 
       } 
      ] 
     } 
    ) 
    url = self.SLACK_HOOK 
    req = urllib2.Request(url, data, {'Content-Type': 'application/json'}) 
    f = urllib2.urlopen(req) 
    f.close() 

誰もがこのようなことを試みましたか?助けてくれてありがとう!

答えて

1

確かにそれを行うことができます。しかし、SlackはTwitter共有ボタンをすぐに提供しないので、あなたのスクリプトはその機能を実装する必要があります。だから、あなたのTwitterの共有ボタンはあなたのスクリプト(他のメッセージボタンのようなもの)を呼び出すでしょうし、あなたのスクリプトは正しいTwitter APIsなどを呼び出すことによってメッセージの内容をTwitterに転送する必要があります。

関連する問題