Hi I'm trying to get the youtube user name and the thumbnail with a youtube app. I´m using the v3.0 and the javascript library.
I'm following this example and docs:
https://developers.google.com/youtube/v3/code_samples/javascript
https://developers.google.com/api-client-library/javascript/reference/referencedocs
I don't have problems with the autentication but I don't know how to get de user name and image.
Somebody knows?
You can call channels->list with "part=id & mine=true"
GET https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&key={YOUR_API_KEY}
Id is the channel's ID.
You can get the channel's title from response under snippet.title. This is what you need as usernames are not useful anymore.
From snippet.thumbnails.(key), you can pick the default, medium or high resolution thumbnail, and get it's width, height and URL.
This is what you are looking for to greet, but if you want to go deeper you can check if that account is linked with Google+ and use googleplususerid to retrieve more information via Google+ API.
https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&access_token = [YOUR TOKEN]
YOU MUST get Oauth code and exchange it for Access Token, to :( complex to give you full answer HERE
Here's how I had to modify my requests to make it work with authentication (otherwise I kept getting a "dailyLimitExceededUnreg" error in the response):
Don't include the "key={YOUR_API_KEY}" in the URL.
Instead, add a HTTP header "Authorization: Bearer {ACCESS_TOKEN}"
Related
I use “google-ads-api” to manage google ads. And api needs “customer_account_id” to initialization. However, I Couldn’t found how to get “customer_account_id” programmatically from user.
I used “react-google-login” in front-end, but there is no “customer_account_id” in the response. What is the best way to get customer_account_id?
You'll have to use the CustomerService's ListAccessibleCustomers method. This request does not require a customer_account_id and you can use it to obtain all Google Ads account IDs that the authenticated user has access to.
See the documentation for details.
I believe that in google-ads-api the relevant class is called AccessibleCustomersService.
I want to fetch all comments of a post on facebook (my post and my friends post) using my access token.
I already have a post id, but when I call FB.api('/{post_id}/comments?access_token=xxxx), it returns error code 100 with the description:
Unsupported get request. Object with ID
'988927087866664_1344444165648286' does not exist, cannot be loaded
due to missing permissions, or does not support this operation. Please
read the Graph API documentation at
https://developers.facebook.com/docs/graph-api
Facebook also approved publish_actions permission for my website.
Thank you for your help
Last month Instagram API was updated and I can't understand how work with it.
For example I want to get images via tag nexus5x.
I do request to https://api.instagram.com/v1/tags/nexus5x?access_token=access_token
and response is
200
'{"meta":{"code":200},"data":{"media_count":5066,"name":"nexus5x"}}'
Can you explain me what to do next?
I also tried get recent items
https://api.instagram.com/v1/tags/nexus5x/media/recent?access_token=access_token
but get this response
200 '{"pagination":{"deprecation_warning":"next_max_id and min_id are
deprecated for this endpoint; use min_tag_id and max_tag_id
instead"},"meta":{"code":200},"data":[]}'
P.S. App in sandbox.
You are in Sandbox mode, so it will return only media from your sandbox authorized user, here is information about this:
As another example, let's consider an endpoint that returns a list of
media: /tags/{tag-name}/media/recent. The response returned by this
endpoint will contain only media with the given tag, as expected. But
instead of returning media from any public Instagram user, it will
return only media that belongs to your sandbox users, restricted to
the last 20 for each user.
So if u add a post in instagram with the hashtag then it will show up in api response, this is restriction in sandbox mode
Here is the link to more details about Sandbox mode: https://www.instagram.com/developer/sandbox/
I tried doing a DELETE request to /media/{id} in the API console on their website, after authenticating with my own account and finding a photo id, but it said 405 METHOD NOT ALLOWED. Plus there are obviously built in requests for deleting comments, likes, etc.
Is there a workaround for this, or is it hopeless?
There is no API endpoint for delete media and there is not plan to add in near future
Reference : https://developers.facebook.com/docs/instagram-api/reference/ig-user/media#updating
Thanks
I'm trying to set up a javascript function to post a status to a twitter account using POST statuses/update, details here: https://dev.twitter.com/docs/api/1/post/statuses/update. The goal is a Twitter post similar to the open graph actions on Facebook.
I'm using jQuery ajax to make the post request, here's what I have so far:
$.ajax
({
type: "POST",
url: "https://api.twitter.com/1/statuses/update.json",
headers: jsonData,
data: {},
dataType: "jsonp",
success: function( data )
{
}
});
I believe that I need to generate a header something like this for security:
Authorization: OAuth oauth_consumer_key=consumerKey, oauth_nonce=nonce,
oauth_signature=signature, oauth_signature_method="HMAC-SHA1",
oauth_timestamp=timestamp, oauth_token=userToken, oauth_version="1.0"
I have the consumer key for my app, I can generate a nonce, I'm generating the signature and timestamp using the methods from this question Twitter OAuth authentication in javascript. The only thing I have left is th oauth_token, which I believe is the token of the user whose feed I wish to post to. Please correct me if I'm wrong about that.
The problem is, I have absolutely no idea how to get this token from the user in order to post to their feed. I've spent the last 2 hours running around in circles through Twitter's oAuth documention without finding anything that looked useful; everything I've found was either flowcharts with no code examples or predicated on my code already having the user's oAuth token.
My question is this: how can I get the logged in user's oAuth token using javascript?
If that is not possible, I have another page where I am currently storing the user's twitter id in the database with their permission, getting their token and databasing it in PHP would also be satisfactory, assuming it doesn't change very frequently.
In order to obtain the oauth_token you need to follow the authentication process. Your application needs to be authorized to act on the behalf of the user.
I would recomend to take some time first and learn how OAuth exactly works (there is a lot of information available) and then implement it in your app. (http://hueniverse.com/oauth/)
You could also benefit from a library which will make your life easier. (in your case, look at: https://dev.twitter.com/docs/twitter-libraries#php).
Hope this has been useful.
Here is example for get twitter oauth token and post tweet in twitter .
Code sample is in php .
http://www.phpgang.com/how-to-post-tweet-on-twitter-with-php_414.html
1) to obtain the oauth token you need to follow the authentication process.
2) and your application needs to be authorized to act on the behalf of the user.
you can also see this twitter example for better understanding how it works
In this use can see the process of authorized user and post and get json result.
https://dev.twitter.com/rest/tools/console
I hope this will help you.
thanks