2 posts in this topic

Hi please try to add this function

public function googleShortLink($url){
$postData = array('longUrl' => $url, 'key' => 'AIzaSyB-waKCO7W_XcFkPvOTgZUHr0fVO1XXUs0');
$jsonData = json_encode($postData);

$curlObj = curl_init();

curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url');
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curlObj, CURLOPT_HEADER, 0);
curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
curl_setopt($curlObj, CURLOPT_POST, 1);
curl_setopt($curlObj, CURLOPT_POSTFIELDS, $jsonData);

$response = curl_exec($curlObj);

//change the response json string to object
$json = json_decode($response);
curl_close($curlObj);
return $json->id;

}

to Class plgContentBt_socialshare (file bt_social_share.php)

Then add this code

$link_article = $this->googleShortUrl($link_article);

right after line

public function getTwitterButton($link_article, $langTagArr) {

This solution use google shortener.

I hope it work correctly.

Cheers

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now