Youtube Share Problem - SocialEngine.com


Blog News | Dulisha | Saturday, 06 June 2015 15:53

Duh? So you have problem to share YouTube video on your SocialEngine? No Worries! Solution is below:







Important: Create a project in the Google Developers Console and obtain authorization credentials so your application can submit API requests.
Replace &key=AIzaSyAaiZ4dWnjI69EJRhH8U1GaS-ncllMs8bY with your key.

- Open /application/modules/Video/controllers/IndexController.php
- Find line: 956 or "public function checkYouTube($code)"
  Select: if (!$data = @file_get_contents("http://gdata.youtube.com/feeds/api/videos/".$code)) return false;
  and replace with:
  if (!$data = @file_get_contents("https://www.googleapis.com/youtube/v3/videos?id=" . $code . "&key=AIzaSyAaiZ4dWnjI69EJRhH8U1GaS-ncllMs8bY&part=snippet&type=video")) {
            return false;
   }

- Find line 973 or search for "public function handleInformation($type, $code)"
  Select
        $yt = new Zend_Gdata_YouTube();
        $youtube_video = $yt->getVideoEntry($code);       
        $information = array();
        $information['title'] = $youtube_video->getTitle();
        $information['description'] = $youtube_video->getVideoDescription();
        $information['duration'] = $youtube_video->getVideoDuration();

  Replace
        $data = @file_get_contents("https://www.googleapis.com/youtube/v3/videos?id=" . $code . "&key=AIzaSyAaiZ4dWnjI69EJRhH8U1GaS-ncllMs8bY&part=snippet&type=video");
       $jfo3 = json_decode($data, true);
       $information = array();

       foreach ($jfo3['items'] as $val) {
                  $information['title'] = $val['snippet']['title'];
                  $information['description'] = $val['snippet']['description'];
                  $information['duration'] = '';
       }


Save file, upload it to server and your are done. Since, Video module is using old API from Youtube, and this is changed from V2 to V3. If you have some trouble, you can always get this quick fix for $20. Use our contact page for more.