Support » Plugin: SCS YouTube Auto Poster » Troubleshooting

  • Hi there

    I believe this plugin is exactly what I’m looking for – a way to automatically publish a post of the video I just published on my YouTube channel.

    However, try as I might, I can’t get it to work.

    I’ve setup the API and all settings (and as far as I’m aware, I set it up correctly), saved it, then hit the “Make YT Posts” button, and I simply get the error “Video 1: [] already posted!”.

    I set the “Publish After date” to a date immediately before one of the more recent videos I published on YouTube, but hadn’t published on the site, but it didn’t seem to pick it up at all.

    Any help would be much appreciated!

Viewing 1 replies (of 1 total)
  • Plugin Author Mike Mind

    (@mikemindme)

    Hi,

    I just saw your message thanks to Eissa Jamil, who also shared this fix:

    //this gets the latest 20 videos from youtube
    function scs_ytap_getYtVideoListData($scs_apikey, $scs_channelId, $scs_noofvids, $scs_publishedAfter, $scs_publishedBefore)
    {
        //var_dump($scs_publishedAfter);
        //var_dump($scs_publishedBefore);
        $orderbydate = "&order=date";
        if ($scs_publishedAfter != "") {$scs_publishedAfter = "&publishedAfter=" . $scs_publishedAfter . "T00%3A00%3A00.0Z";
            $orderbydate = "";}
        if ($scs_publishedBefore != "") {$scs_publishedBefore = "&publishedBefore=" . $scs_publishedBefore . "T00%3A00%3A00.0Z";
            $orderbydate = "";}
    
        $yturl = "https://www.googleapis.com/youtube/v3/search?key=" . $scs_apikey . "&channelId=" . $scs_channelId . "&part=snippet,id" . $orderbydate . "&maxResults=" . $scs_noofvids . $scs_publishedAfter . $scs_publishedBefore;
        // echo $yturl;
        $json = curl_get_contents($yturl);
        //$json = file_get_contents($yturl); // failure here on my server
        $data = json_decode($json, true);
        // echo $data;
        return $data;
    }
    
    function curl_get_contents($url,$useragent='cURL',$headers=false, $follow_redirects=false,$debug=false) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        if ($headers==true){
            curl_setopt($ch, CURLOPT_HEADER,1);
        }
        if ($headers=='headers only') {
            curl_setopt($ch, CURLOPT_NOBODY ,1);
        }
            if ($follow_redirects==true) {
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
        }
        if ($debug==true) {
            $result['contents']=curl_exec($ch);
            $result['info']=curl_getinfo($ch);
        } else {
            $result=curl_exec($ch);
        }
        curl_close($ch);
        return $result;
    }

    Hope this will work for you as well. Thanks Eissa!

Viewing 1 replies (of 1 total)
  • The topic ‘Troubleshooting’ is closed to new replies.