I'm currently using CodeBird to post tweets via PHP on my website. I've been using Bit.ly to post short URLS within those tweets. I would prefer to use the t.co short links that twitter creates but I am unsure how to do this.
\Codebird\Codebird::setConsumerKey("???", "???");
$cb = \Codebird\Codebird::getInstance();
$cb->setToken("???", "???");
$params = array('status' => $VideoTitle.' | Visit -> '.$VideoShortUrl, 'media[]' => 'hdefault.jpg');
$reply = $cb->statuses_updateWithMedia($params);
$array = json_decode(json_encode($reply), True);
Above is the code I use alongside the codebird.php file. Every tweet includes a title, url, and image. I'm looking to have the link I post (which is always 28+ characters) replaced with the twitter t.co short link.
I've read the twitter API documentation and other related questions on SOF but still have come up empty handed. I know twitter creates the link as soon as I post a tweet cause the array returns the short URL with all the other tweet details instantly.
The Twitter API says:
Links will be wrapped when Twitter receives a Tweet using POST statuses/update or a direct message using POST direct_messages/new.
I was thinking maybe codebird's wrapper wasn't unwrapping the links when it was returning the data, but I couldn't find anything there either. Does anyone know how I would go about replacing my URL with the t.co URL in the process of posting a tweet?
p.s
I've read that sometimes the short url creation 'could' be delayed, but none of my links are being changed. Also on a side note almost all the tweets are under 140 characters even with the long URL.