Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Feb 19, 2015 @ 09:32
    Ismail Mayat
    0

    How to get youtube channel subscribers

    Anders,

    I have downloaded the google razor file and have browsed through source code but cannot see how to get you tube channel subscriber data. I have successfully authenticated and have a service, i need to for a given you tube user / channel (not sure what i need to pass in ) get channel subscriber count.  Any ideas on how to do this / implement if not already done?

    Many thanks

     

    Ismail

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Feb 19, 2015 @ 09:53
    Ismail Mayat
    0

    Anders

    Update to that last question i was using 0.1.2 and have updated to 0.9.0 I can see youtube stuff there however my facebook and twitter is giving errors

    FacebookPostSummary[] GetFacebookPostsForUser(string facebookId, int noOfPosts);

     

            FacebookPostSummary[] GetStormFaceBookPosts(int noOfPosts);

     

            TwitterTimeline GetTimelineForUser(string twitterUserName, int noOfTweetsOfTimeLine);

    I guess in latest version this is not the way to do things?

    Regards

    Ismail

  • Anders Bjerner 476 posts 2885 karma points MVP 6x admin c-trib
    Feb 19, 2015 @ 09:55
    Anders Bjerner
    0

    Hi Ismail,

    The current release of Skybrud.Social for Umbraco 7 doesn't support YouTube. When authenticating with Google, this package will only send the email and profile scopes to the login dialog, so the code won't be able to access your YouTube data.

    If everything go as planned, I will make a new release over the weekend. This will include the option to specify which scopes that should be sent to the login dialog.

    It is also possible to implement the authentication your self, and specify the necessary YouTube scope. If you're interested in doing so, you can find some inspiration here: https://github.com/abjerner/Skybrud.Social.Umbraco/blob/master/src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Dialogs/GoogleOAuth.aspx.cs#L111 I will then try to look up an example on how to call the API ;)

  • Anders Bjerner 476 posts 2885 karma points MVP 6x admin c-trib
    Feb 19, 2015 @ 10:19
    Anders Bjerner
    0

    0.9.0 has some breaking changes. The repository has been updated to use most recent version of Skybrud.Social. I'll make sure to update the Razor examples as well.

    With the release of Skybrud.Social 0.9.0, rather than calling service.Methods.GetPosts(...), you should now call service.Posts.GetPosts(...). The new method will return an instance of FacebookPostsResponse, where the property Body then is an array of the posts (now of type FacebookPost rather than FacebookPostSummary).

    Similarly for Twitter, you can now call service.Statuses.GetUserTimeline(...) which will return an instance of TwitterTimelineResponse, and the property Body will be an array of TwitterStatusMessage.

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Feb 19, 2015 @ 10:31
    Ismail Mayat
    0

    Anders,

    First thing is first need to fix the breaking changes, so for twitter i have 

     var twitter =

                    _externalServicesNode.GetPropertyValue(Constants.ExternalServices.StormTwitteroAuth) as TwitterOAuthData;

                // Check whether the OAuth data is valid

                if (twitter != null && twitter.IsValid)

                {

                    _twitterService = twitter.GetService();

                }

    The getservice is from skybrudumbraco and i have updated that to latest version, further down in my code i have

    var timeline = _twitterService.Statuses.GetUserTimeline(twitterUserName, noOfTweetsOfTimeLine);

    At this point I am expecting a TwitterTimeline object however i am getting TwitterTimeLineResponse and from this I cannot get the tweets am i missing something?

    Regards

    Ismail

     

     

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Feb 19, 2015 @ 10:35
    Ismail Mayat
    0

    Ignore last message i need .Body then I can get to what i need, many thanks for help so far I will be back with more questions hahha

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Feb 19, 2015 @ 10:43
    Ismail Mayat
    0

    For facebook to get posts for currently authenticate user would this be valid

     return _facebookService.Posts.GetPosts("me", noOfPosts).Body.Data;

    Regards

    Ismail

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Feb 19, 2015 @ 11:35
    Ismail Mayat
    0

    Anders,

    Some progress all the twitter stuff is working again and the facebook stuff bar Me bit. I need to get posts for currently authenticated token, so i am doing

    _facebookService.Posts.GetPosts("me", noOfPosts).Body.Data;

    I get An active access token must be used to query information about the current user however this token is valid as i can do other facebook stuff like get page for user.

    Any ideas?

    Cheers

    Ismail

  • Anders Bjerner 476 posts 2885 karma points MVP 6x admin c-trib
    Feb 19, 2015 @ 11:53
    Anders Bjerner
    0

    Not sure if I have encountered that one before. How did you obtain the token?

    This tool might also help you to find on whats going on: https://developers.facebook.com/tools/debug/accesstoken/

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Feb 19, 2015 @ 12:23
    Ismail Mayat
    0

    Anders,

    I created the token from that url as i wanted a non expiring one.  It was working till the update after which i updated my code so orignally i was getting current user posts using code 

     FacebookPostsResponse response = FacebookPostsResponse.ParseJson(_facebookService.Methods.Raw.GetPosts("me"));

                return response.Data;

    now i am doing 

    return _facebookService.Posts.GetPosts("me", noOfPosts).Body.Data;

    Regards

    Ismail

     

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Feb 19, 2015 @ 12:49
    Ismail Mayat
    0

    Anders,

    I am trying to get token for instagram when i authosise i get 

    Method not found: 'Skybrud.Social.Instagram.Objects.InstagramUser Skybrud.Social.Instagram.Responses.InstagramUserResponse.get_Data()'.

    I have updated both skybrd and skybrud umbraco. Apologies for the spamming ;-}

    Cheers

    Ismail

  • Anders Bjerner 476 posts 2885 karma points MVP 6x admin c-trib
    Feb 19, 2015 @ 13:08
    Anders Bjerner
    1

    The current version of Skybrud.Social for Umbraco 7 uses Skybrud.Social v0.1.2, but if you install it via NuGet, I think Skybrud.Social v0.9.0 will be installed instead, and things then won't work. That is one of the reasons why there soon will be a new release of Skybrud.Social for Umbraco 7.

    If you can't wait, you should be able to pull the latest code from the repository and build it yourself.

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Feb 19, 2015 @ 14:37
    Ismail Mayat
    0

    Anders,

    Awesome pulled down latest version and built that and i now have a token woohoo.  With regards to youtube i cannot see methods to get channel for a user?  I am going to branch and try and implement unless you have done it already? If not I will give it a go then maybe pull request ;-}

    Many thanks for you help so far, you should speak to warren and get onto uHangout to show this awesome package?

    Regards


    Ismail

  • Anders Bjerner 476 posts 2885 karma points MVP 6x admin c-trib
    Feb 19, 2015 @ 21:54
    Anders Bjerner
    1

    The YouTube implementation is a bit limited at the moment, but is also one of the things I'm working on for the next release.

    The current v0.9.0 doesn't support fetching a list of channels, but I have now added that logic (had implemented some of the code already). You can grab the most recent DLL from my Dropbox. If I can find the time, I will try to make a new NuGet/GitHub release over the weekend.

    To get a list of the channels for the authenticated user, you can now do the following:

    YouTubeChannelsResponse response = service.YouTube.Channels.GetChannels();
    
    foreach (YouTubeChannel item in response.Body.Items) {
    
        string id = item.Id;
    
        string title = item.Snippet.Title;
    
        long subcribers = item.Statistics.SubscriberCount;
    
    }
    

    If you instead want to get a list of channels for a specific user, you can do as:

    YouTubeChannelsResponse response = service.YouTube.Channels.GetChannels("latenight");
    
  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Feb 20, 2015 @ 10:31
    Ismail Mayat
    0

    Anders,

    Im getting insufficient permission error when trying to get channels for a user?  Am I missing something on my app configuration in https://console.developers.google.com/ ??

    Regards

    Ismail

  • Anders Bjerner 476 posts 2885 karma points MVP 6x admin c-trib
    Feb 20, 2015 @ 10:36
    Anders Bjerner
    0

    Yes, I think you need to enable access to the YouTube Data API if you haven't done so already.

    Also when authenticating, it is important that you set either the YouTube manage scope or YouTube readonly scope. You can check at https://security.google.com/settings/security/permissions whether you have granted one of these scopes to your app.

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Feb 23, 2015 @ 14:48
    Ismail Mayat
    0

    Anders,

    Still getting insufficient permissions error,  so here is what I did, I went to https://console.developers.google.com/ and create a project Next i enabled youtube analytics api and youtube data api.  Then under credentials i created Client ID for web application, I then updated my google data type to use the generated client id and secret.  Then in umbraco did the authorize.  In my code I get the data and create service all that works, just when I make the call to get stats i get the error.  One thing the account I am using does not have billing information set, not sure if that would make a difference?

    Regards

    Ismail

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Feb 23, 2015 @ 18:09
    Ismail Mayat
    0

    Anders,

    I have been stepping through the code and have got the access token that is created, i then hit https://www.googleapis.com/oauth2/v1/tokeninfo?access_token= and passed in the token this shows me what that token has 

    scope"https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"

    So even though i have enabled youtube i cannot see it as a scope, I cannot for the live of me see how to add that scope?

    Any ideas?

    Cheers

    Ismail

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Feb 23, 2015 @ 18:17
    Ismail Mayat
    0

    Anders,

    Right I think I know what the issue is, in GoogleOAuth.aspx.cs line 34 you are doing 

    // Declare the scope

                    GoogleScopeCollection scope = new[] {

                        GoogleScope.OpenId,

                        GoogleScope.Email,

                        GoogleScope.Profile

                    };

    No you tube here, I will update the code add youtube scopes, unless there is a way in google backend to allow?

    Regards

    Ismail

     

  • Anders Bjerner 476 posts 2885 karma points MVP 6x admin c-trib
    Feb 23, 2015 @ 18:26
    Anders Bjerner
    0

    Yes, if you're using the OAuth dialog from my package, it will only set/require basic scope. Nothing for YouTube, nothing for Analytics etc.

    One of my plans for the future is that it should be possible to configure this via a prevalue editor. Meanwhile you can simply update the code to:

    GoogleScopeCollection scope = new[] {
        GoogleScope.OpenId,
        GoogleScope.Email,
        GoogleScope.Profile,
        YouTubeScope.Readonly
    };
    

    That gives your app read permissions to your YouTube account ;)

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Feb 23, 2015 @ 19:26
    Ismail Mayat
    0

    Anders,

    Cool will give that go, frustrating but learning quite a bit lol. You should speak to Warren and do uhangout on this project its very very useful.

    Regards

     

    Ismail

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Feb 24, 2015 @ 10:31
    Ismail Mayat
    0

    Anders,

    You say "That gives your app read permissions to your YouTube account" however i want subscriber stats for other users youtube channels i take it i have to add a different scope? 

    Regards

    Ismail

  • Anders Bjerner 476 posts 2885 karma points MVP 6x admin c-trib
    Feb 24, 2015 @ 10:34
    Anders Bjerner
    100

    In most cases, no. It just means that you're accessing the API on behalf of your own Google/YouTube account, but your account will still have access to public information from other accounts and channels ;)

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Feb 24, 2015 @ 11:05
    Ismail Mayat
    0

    Anders,

    This works a treat, many many thanks for all your help h5yr!!!!

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft