So I'm trying to get the channel profile picture for a YouTube channel by using the channelId.
I would like to do it simply by adding the channelId to a URL and get the image that way.
Facebook has something similar where you use this URL:
http://graph.facebook.com/user_id/picture?type=square
Google+ has it too, found this question here. Sadly it didn't work for YouTube (I couldn't get it to work)
Hope someone has a solution!
Thanks in advance :)
You can use channels->list request for that.
In response you will get snippet.thumbnails."default".url for that
For authenticated user's channel:
GET https://www.googleapis.com/youtube/v3/channels?part=snippet&mine=true&fields=items%2Fsnippet%2Fthumbnails&key={YOUR_API_KEY}
Or for any channel ID:
GET https://www.googleapis.com/youtube/v3/channels?part=snippet&id+CHANNEL_ID&fields=items%2Fsnippet%2Fthumbnails&key={YOUR_API_KEY}
In PHP, I got it with:
$url = "https://www.googleapis.com/youtube/v3/channels?part=snippet&fields=items%2Fsnippet%2Fthumbnails%2Fdefault&id={$channelId}&key={$API}";
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
$channelOBJ = json_decode( curl_exec( $ch ) );
$thumbnail_url = $channelOBJ->items[0]->snippet->thumbnails->default->url;
a little bit late, but maybe interesting for others:
just create a comma separated list for the different channelIds and then call
https://www.googleapis.com/youtube/v3/channels?part=snippet&id='+commaSeperatedList+'&fields=items(id%2Csnippet%2Fthumbnails)&key={YOUR_API_KEY}
therefore you don't have to send a request for each item
Related
The newly added (05/02) User Channels resource seems to be dead. When I attempt to access this data I always receive an error that says "Unknown subresource channels".
Can anyone confirm that this functionality is actually working?
I've tried retrieving it a couple of different ways:
$channels = $this->client->chat
->services($this->ipmSid)
->users($memberId)
->channels
->read(); // I've also tried ->fetch();
and then I tried using the link that is provided when you fetch a member and feeding that directly into curl like this:
$member = $this->client->chat
->services($this->ipmSid)
->users($user_id)
->fetch();
$url = $member->links['user_channels'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($process, CURLOPT_USERPWD, $this->sid . ":" . $this->token);
$resp = curl_exec($ch);
Both ways result in a 500 error "Twilio Exception Unknown Subresource Channels".
Thanks for any tips!
It is not documented well. You need to use userChannels.
channels = $this->client->chat
->services($this->ipmSid)
->users($memberId)
->userChannels
->read();
I'm trying to get the entered information on a survey of SurveyMonkey through the API. But i'm getting the following return message: "Could not validate access to survey at this time, please try again later.", with status 5 (System Error).
I'm working with a APP in Draft status. All the scopes in my app are put on optional. And other api calls (like get_survey_list) do give me data.
I'm working with php, but the API console (https://developer.surveymonkey.com/docs/api_console/) also gives me these results.
Is there an extra permission layer i'm missing? Do ppl need to approve something through oauth?
The API console is for V2 of the API (which is either deprecated, or likely to be deprecated soon), I would recommend using V3 (https://developer.surveymonkey.com/api/v3)
You can fetch the list of surveys using
GET /v3/surveys
And you can get a specific survey with
GET /v3/surveys/<id>
And follow down the path to get individual pages/questions, or if you want the entire survey expanded at once, use:
GET /v3/surveys/<id>/details
With regards to the request you are doing with API v2, I'd probably need a bit more information, if you are doing a POST with an empty body to get_survey_list and are getting that issue I'd probably contact their customer support to look into it as it looks like a server error. But I would recommend going to V3 and see if everything works fine for you.
Like the general posted, v3 works fine. Here is the code of my POC that works:
// GET USER
$requestHeaders = array(
'Content-Type: application/json',
'Authorization: Bearer [ACCESS_TOKEN]',
);
$url = 'https://api.surveymonkey.net/v3/users/me?api_key=[API_KEY]';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders);
$result = curl_exec($ch);
curl_close($ch);
The above is the just a simple call to get the basic info of the user.
The next call get's the answers given in the responses that are given through a specific collector.
// GET THE ANSWERS OF THE SURVEY
$requestHeaders = array(
'Content-Type: application/json',
'Authorization: Bearer [ACCESS_TOKEN]',
);
$url = 'https://api.surveymonkey.net/v3/collectors/[COLLECTOR_ID]/responses/bulk?api_key=[API_KEY]';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders);
$result = curl_exec($ch);
curl_close($ch);
You can also import the API into Postman. There is a button for this on the documentation site. Pretty nice :)
I am developing an app in which I want to know if a facebook authorized user has a verified profile or not. I can see that there is a is_verified field that facebook provides. I am just not getting it in the response I get from OAuth. Is there any permissions issue? I am using permissions public_profile,email. Please guide me on this.
You can ask 'is_verified' field in your query. You can try below code as a sample and u can take the appropriate part of the code to integrate in yours. public_profile,email permission is enough to get this field. result will be a bolean
$fb_page = 'barackobama'; //any fb page,fb profile
$access_token = ''; //your access token
$url = "https://graph.facebook.com/v2.2/".$fb_page.'
?access_token='.$access_token.'&fields=is_verified';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($curl);
curl_close($curl);
$details = json_decode($result,true);
echo "verified:".$details['is_verified'];
I'm using PHP and CURL to try and get all my account's events from EventBrite's web service.
I'm running this script (edited down slightly):
$curl = curl_init();
$hdr = array();
$hdr[] = 'Authorization: Bearer <MY TOKEN>';
$hdr[] = 'Content-type: application/json';
curl_setopt($curl, CURLOPT_HTTPHEADER, $hdr);
curl_setopt(
$curl,
CURLOPT_URL,
'https://www.eventbriteapi.com/v3/users/me/owned_events/?status=live'
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$events = curl_exec($curl);
print_r($results);
But the status=live parameter is not taking effect and all events including drafts are being returned.
Has anyone successfully achieved a list of live events using EventBrite's API and if so, can you advise me how you managed and where I went wrong?
I'm unsure if I just helped you via email, but after troubleshooting I've deducted that this will only return 'live' events if you also pass in 'started' as a status parameter.
Ex.) 'https://www.eventbriteapi.com/v3/users/me/owned_events/?status=live,started'
I hope this helps!
For the benefit of anyone else with a similar problem, the issue was the "Content-Type" header. Remove this, and all is well with the world.
Can someone tell me how can I get the feedburner subscribers count as text using php? I am trying the following, but it does not work as I think feedburner has changed the contents of the xml file.
Thanks for any help.
$whaturl="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=USERNAME";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $whaturl);
$data = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];
echo $fb;
Need to alter line 7 to:
$fb = $xml->feed->entry->attributes()->circulation;
//Much later edit
I actually have a couple of posts on my blog by now with code for fetching facebook / twitter / feedburner counts. Code with APC caching is here:http://www.glowingminds.co.uk/facebook-likes-twitter-follows-and-feedburner-count-in-php-with-curlsimplexml-deluxe/