Search code examples
pythontwittertumblrpytumblr

How to add a custom tweet to Tumblr API?


I have the following code to post a blog on Tumblr through Tumblr API.

 post = client.create_text("xxx.tumblr.com",
                                      state="published",
                                      tags=utag_list,
                                      format='html',
                                      tweet=tweet.encode('utf-8'),
                                      slug=sluged_header,
                                      title=news.head_line.encode('utf-8'),
                                      body=body)

Strangely the tweet parameter doesnt do anything.

Looking at my blog source, I can see:

<li><a href="https://twitter.com/intent/tweet?text=Teenagers%20rescue%20elderly%20couple%20from%20sinking%20after%20car%20crashes%20into%20lake%20-%20Teenage%20wind-surfing...%20http%3A%2F%2Ftmblr.co%2FZ_F3uj1qlCL9u" class="share-item twitter" target="_blank">Tweet</a></li>

This is the default tweet message generated. Somehow my custom tweet message is completely ignored. And not generated in source. Hence the tweet sharing doesn't see the custom message. Any advice please?


Solution

  • I found the solution. This happened because the tweet was slightly over 140 chars and got ignored without raising any further exceptions.

    This bug has been confirmed by the Tumblr team and will be raised and fixed internally.

    In the mean while make sure the tweet is 100% below 140 chars.