learningprobs Posted August 22, 2016 Share Posted August 22, 2016 (edited) Hello, This is the first API I am trying to work with and would like to know if you could guide me a little bit please. I am trying to parse a url as it shows here: https://developer.vimeo.com/api/upload/videos As you can see, the format is: GEThttps://api.vimeo.com/me And it should return something like: "upload_quota":{ "space":{ "free":53525865655, "max":53687091200, "used":161225545 }, "quota":{ "hd":true, "sd":true } }, I took a random user on Vimeo as an example and tried to output the data based his account data but no luck: <?php $api_request_url = 'https://api.vimeo.com/user1577007'; curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json')); curl_setopt($ch, CURLOPT_URL, $api_request_url); curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); $api_response = curl_exec($ch); $api_response_info = curl_getinfo($ch); curl_close($ch); // Response HTTP Status Code echo $api_response_info['upload_quota']; ?> Any idea what am I actually doing wrong please? Thank you. Edited August 22, 2016 by learningprobs Quote Link to comment https://forums.phpfreaks.com/topic/301967-struggling-with-api-to-parse/ Share on other sites More sharing options...
maxxd Posted August 22, 2016 Share Posted August 22, 2016 Try using the playground they have set up here - it looks like your endpoint call is set up incorrectly. There may be something more egregious that I'm missing as I'm not terribly familiar with the Vimeo API, but I'd start at the malformed request. Quote Link to comment https://forums.phpfreaks.com/topic/301967-struggling-with-api-to-parse/#findComment-1536453 Share on other sites More sharing options...
Barand Posted August 22, 2016 Share Posted August 22, 2016 Erm, if it really were egregious then you wouldn't miss it 2 Quote Link to comment https://forums.phpfreaks.com/topic/301967-struggling-with-api-to-parse/#findComment-1536454 Share on other sites More sharing options...
maxxd Posted August 22, 2016 Share Posted August 22, 2016 Erm, if it really were egregious then you wouldn't miss it I never trust my brain before my third cup of coffee... Quote Link to comment https://forums.phpfreaks.com/topic/301967-struggling-with-api-to-parse/#findComment-1536457 Share on other sites More sharing options...
learningprobs Posted August 22, 2016 Author Share Posted August 22, 2016 Thanks for sharing this beautiful tool I was not aware of :-) it looks like the problem is actually from the id I am inputting, I thought the "page number" was the id of the user profile but when I try to input this number in the field I am getting the same error... This is weird, no idea what they refer as "page" as I have also tried a video page and it says "error 500". Quote Link to comment https://forums.phpfreaks.com/topic/301967-struggling-with-api-to-parse/#findComment-1536458 Share on other sites More sharing options...
maxxd Posted August 23, 2016 Share Posted August 23, 2016 'page' is defined as "The page number to show". 'per_page' is defined as "Number of items to show on each page. Max 50.". There's also an 'offset' key, which according to the documentation you shouldn't supply. The assumption here would be that 'page' and 'per_page' work together for paginated search results; for instance, to show videos 51-101 of user 1577007's playlist, you would call to 'https://api.vimeo.com/users/1577007/feed?page=2&per_page=50'. Of course, when you do that in the playground, you're told that "The user is not allowed to perform that action." Which means there must be more to it - perhaps you need an API key, or perhaps you can't just pull a random stranger's playlist. If you select 'likes' on the same user, though, you do in fact get some data back, so I'm thinking you may need the user's specific permission to grab his or her feed contents, but that same user's likes are public. Regardless, your best bet is to start by reading the documentation and experimenting with the playground API they've set up. Quote Link to comment https://forums.phpfreaks.com/topic/301967-struggling-with-api-to-parse/#findComment-1536468 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.