Convert Tweets to Beautiful Images

Paste link of any Tweet and Click "Generate"

Code


// Bruzu API key get yours at https://bruzu.com
$apiKey = "BRUZU-YOURKEY";
// How to get this token:- https://developer.twitter.com/en/docs/authentication/oauth-2-0/bearer-tokens 
$bearerToken = "";

// Tweet ID
$id="1430860679565647872";

// Create a stream
$opts = array(
  'http'=>array(
    'method'=>"GET",
    'header'=> "Authorization: Bearer ".$bearerToken."\r\n"
  )
);

$context = stream_context_create($opts);
$json = file_get_contents('https://api.twitter.com/2/tweets/'.$id.'?expansions=author_id&user.fields=name,username,verified,profile_image_url', false, $context);
$tweet = json_decode($json,true);

$apiLink = "https://img.bruzu.com/?bi=https%3A%2F%2Fsource.unsplash.com%2FeICUFSeirc0%2F1200x630&bi.o=NaN&h=630&w=1200&a.tp=rect&a.ox=center&a.oy=center&a.x=600&a.y=315&a.w=1024&a.h=380&a.fill=white&a.sc=gray&a.o=0.8&a.rx=20&a.ry=20&b.tp=textbox&b.ox=center&b.oy=center&b.x=600&b.y=388&b.w=905&b.h=149&b.ta=left&b.fs=44&b.lh=1&b.fw=400&b.ff=Inter&b.fontStyle=normal&b.maxHeight=150&c.tp=textbox&c.ox=center&c.oy=bottom&c.x=484&c.y=223&c.w=438&c.h=40&c.fill=%23000000&c.t=".urlencode($tweet['includes']['users'][0]['name'])."&c.ta=left&c.fs=35&c.lh=1&c.fw=400&c.ff=Poppins&c.fontStyle=normal&c.maxHeight=35&d.tp=image&d.x=147&d.y=181&d.w=200&d.h=200&d.sx=0.5&d.sy=0.5&d.ox=left&d.oy=top&d.circleFrame=true&e.tp=textbox&e.ox=center&e.oy=bottom&e.x=484&e.y=260&e.w=438&e.h=29&e.fill=%23806b6b&e.ta=left&e.fs=26&e.lh=1&e.fw=400&e.ff=Open%20Sans&e.fontStyle=normal&e.maxHeight=26&f.tp=image&f.x=983&f.y=183&f.w=397&f.h=321&f.sx=0.2&f.sy=0.2&f.ox=left&f.oy=top&f.src=https%3A%2F%2Fi.imgur.com%2FsT9QS7U.png&d.src=".str_replace("_normal","_200x200",$tweet['includes']['users'][0]['profile_image_url'])."&b.t=".urlencode($tweet['data']['text'])."&e.t=%40".$tweet['includes']['users'][0]['username'];

$png = file_get_contents($apiLink."&ak=".$apiKey);
$imgLink = 'data:image/png;base64,' . base64_encode($png);
// You can use this link into your HTML code 
// <img src="<?=$imgLink?>" >