0
내 Android 앱에 내장 된 YouTube 구독 버튼을 추가하려면 어떻게해야하나요? 내 채널에 구독하는 버튼이 필요하지만 웹 버튼처럼 내 앱에 머물러 있지만 Android 용입니다. 가입 링크를 시도했지만 앱에서 가져옵니다.묻힌 youtube 구독 버튼 android를 구현하는 방법은 무엇입니까?
내 Android 앱에 내장 된 YouTube 구독 버튼을 추가하려면 어떻게해야하나요? 내 채널에 구독하는 버튼이 필요하지만 웹 버튼처럼 내 앱에 머물러 있지만 Android 용입니다. 가입 링크를 시도했지만 앱에서 가져옵니다.묻힌 youtube 구독 버튼 android를 구현하는 방법은 무엇입니까?
Youtube Data API의 subscriptions.insert을 사용하여 인증 된 사용자 채널에 대한 구독을 추가하십시오. 단추를 누르면 코드의이 부분이 실행되도록하십시오.
코드 :
try {
// Authorize the request.
Credential credential = Auth.authorize(scopes, "addsubscription");
// This object is used to make YouTube Data API requests.
youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, credential).setApplicationName(
"youtube-cmdline-addsubscription-sample").build();
// We get the user selected channel to subscribe.
// Retrieve the channel ID that the user is subscribing to.
String channelId = getChannelId();
System.out.println("You chose " + channelId + " to subscribe.");
// Create a resourceId that identifies the channel ID.
ResourceId resourceId = new ResourceId();
resourceId.setChannelId(channelId);
resourceId.setKind("youtube#channel");
// Create a snippet that contains the resourceId.
SubscriptionSnippet snippet = new SubscriptionSnippet();
snippet.setResourceId(resourceId);
// Create a request to add the subscription and send the request.
// The request identifies subscription metadata to insert as well
// as information that the API server should return in its response.
Subscription subscription = new Subscription();
subscription.setSnippet(snippet);
YouTube.Subscriptions.Insert subscriptionInsert =
youtube.subscriptions().insert("snippet,contentDetails", subscription);
Subscription returnedSubscription = subscriptionInsert.execute();
// Print information from the API response.
System.out.println("\n================== Returned Subscription ==================\n");
System.out.println(" - Id: " + returnedSubscription.getId());
System.out.println(" - Title: " + returnedSubscription.getSnippet().getTitle());
}
여기에 추가 참조에 대한 관련 SO thread입니다.
어디서든지 내가 배울 수있는 앱 소스가 있습니까 ?? –