false, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 3 //タイムアウト(秒) ); if(file_exists($datcache)){ //キャッシュがある場合 $json = file_get_contents($datcache); $arr = json_decode($json, true); $html = html_entity_decode($arr['html']); } else { //キャッシュがない場合 $json_url = 'https://publish.twitter.com/oembed?maxwidth=550&dnt=true&url='. urlencode($tweeturl); $ch = curl_init($json_url); curl_setopt_array($ch, $options); $json = curl_exec($ch); $arr = json_decode($json, true); curl_close($ch); if ($arr === NULL) { //json取得失敗 $html = '
' . $tw[1] . '
'; } else { //json取得成功 $html = html_entity_decode($arr['html']); //キャッシュする file_put_contents($datcache, $json); } } if (PLUGIN_TWEET_LAZYLOAD) { //scriptをlazyloadに置換 $twjs1 = ''; $twjs2 = ''; $twjs3 = ''; $html = str_replace($twjs1, $twjs2, $html); if( !in_array($twjs3, $head_tags, true)) { $head_tags[] = $twjs3 ; } } if( in_array('noimg', $tw)){ $twjs4 = 'class="twitter-tweet"'; $twjs5 = 'class="twitter-tweet" data-cards="hidden"'; //画像非表示 $html = str_replace($twjs4, $twjs5, $html); } if( in_array('noconv', $tw)){ $twjs6 = 'class="twitter-tweet"'; $twjs7 = 'class="twitter-tweet" data-conversation="none"'; //リプライを非表示 $html = str_replace($twjs6, $twjs7, $html); } return <<