2014-03-24 103 views
0

透過YouTube API v3和PHP您可以輕鬆地訂閱頻道。的YouTube API V3 PHP - 退訂?

$resourceId = new Google_Service_YouTube_ResourceId(); 
$resourceId->setChannelId($_GET['id']); 
$resourceId->setKind('youtube#user'); 
$subscriptionSnippet = new Google_Service_YouTube_SubscriptionSnippet(); 
$subscriptionSnippet->setResourceId($resourceId); 
$subscription = new Google_Service_YouTube_Subscription(); 
$subscription->setSnippet($subscriptionSnippet); 

$subscriptionResponse = $youtube->subscriptions->insert('id,snippet', 
    $subscription, array()); 

但是我如何取消訂閱頻道?它不記錄

這是爲了這個,我發現的唯一的幫助,但它並沒有說如何使用PHP API做到這一點:https://developers.google.com/youtube/v3/docs/subscriptions/delete

回答

0

你需要知道什麼是訂閱ID。一旦你得到了它,你可以執行刪除:

$youtube->subscriptions->delete($subscription->getId());