mercredi 22 juin 2016

How to send url in tweet from PHP using codebird

I'm sending tweets using Codebird.

I want the tweet to include text and a link (URL)

I have shortened the URL using Google urlshortener API. The result looks like this:

h t t p :// g o o.gl/qZX2sw <-- spaces added to allow posting on SO. Below referred to as "shortened_google_url"

If i include the url in the string like this

$params = array( 'status' => ("some text shortened_google_url") ); $reply = $cb->statuses_update($params);

the resulting Tweet as rendered by Twitter is like this:

    <p class="TweetTextSize TweetTextSize--26px js-tweet-text tweet-text" lang="it" data-aria-label-part="0">
    some text shortened_google_url
   </p>

If I put the link in quotes like this 'status' => ("some text 'shortened_google_url'")

the resulting tweet includes the url as a link (AS I WANT):

    <p class="TweetTextSize TweetTextSize--26px js-tweet-text tweet-text" lang="it" data-aria-label-part="0">
    some text '<a href="shortened_twitter_url" rel="nofollow" dir="ltr" data-expanded-url="shortened_google_url" class="twitter-timeline-link" target="_blank" title="shortened_google_url"><span class="tco-ellipsis"></span><span class="invisible">http://</span><span class="js-display-url">shortened_google_url</span><span class="invisible"></span><span class="tco-ellipsis"><span class="invisible">&nbsp;</span></span></a>'
    </p>

But, the tweet includes the quotes '<a </a>' , which I don't want. I want to send the tweet without quotes around the <a> tag that Twitter generates.

Example: Top tweet with quotes, bottom tweet without above: with quotes, below: without quotes

Aucun commentaire:

Enregistrer un commentaire