How do I list all videos uploaded to Youtube? - php

I'm working with Youtube API and PHP library: http://code.google.com/apis/youtube/2.0/developers_guide_php.html
I'm modifying existing app: http://googlecodesamples.com/youtube/php/YouTubeVideoApp/index.php
That is also available in Zend Gdata library: [no link due to "new users can only post a maximum of two hyperlinks"]
My problem is:
"retrieve my videos" retrieves only 25 and links "back" / "next" are not working :(
The workflow of Youtube API and ZendFramework is really complicated:
index.php calls a javascript function declared in video_app.js
ytVideoApp.listVideos calls ytVideoApp.presentFeed
ytVideoApp.presentFeed sends ajax request operations.php
operations.php strips parameters and calls proper function within itself, that is searchVideos
searchVideos calls echoVideoList
echoVideoList prints the data foreach ($feed as $entry)
ytVideoApp.listVideos updates navigation (back/next buttons)
Existing value: ytVideoApp.MAX_RESULTS_LIST = 200; I also tried to hardcode it, rather than passing via parameter across php, js, ajax. In each case the I receive only 25 results. I tested in on two separate accounts (I do have 2 accounts with more than 25 uploads).
Is there any limitation that remains unknown to me?
Any hints, clues, whatever?

Here is your solution:
http://markmail.org/message/n2px7yheizakzt7y#query:+page:1+mid:vcrj4gmyzfxdtpao+state:results
(click on 'Peter December 5, 2010 - at the top')
As quoted from that link:
Here is the solution that I've come up [with]:
In operations.php find the line: $query->setQuery($searchTerm); and
comment it out.
A few lines below, right under $query->setMaxResults($maxResults);
add this: $query->setAuthor('millenniumpromise');
That's basically it! You can now use the all search type and get
the results published only by millenniumpromise.
I also needed to display the results by published date (most recent
first), so I added $query->setParam('orderby', 'published'); right
below $query->setAuthor('millenniumpromise'); in operations.php
And here is more help from the same players as above:
http://osdir.com/ml/youtube-api-gdata/2010-11/msg00426.html
I must commend Peter and Neil for I have just spent the past week trying to nut this same problem out myself until I found their solution...
Regards,
Adam

Related

get filename from google docs using laravel

My site has a feature where users can upload a link to their google docs file. What I want to do is list all the uploaded links in a place. While doing that I need to show the name of the file that is associated with the link.
I can extract the file id from the link and make sure the link is of google docs. Now I need to find a way to get the filename from that. I tried going through the google developer API for google drive, but it is for uploading/doing anything only on the authorized docs. My issue here is, my users upload the files manually to their docs which I have no control over. All I get is a sharable link and somehow get the name out of it. In addition, a thumbnail will also help.
I have tried doing this, but it throws error
$url = "https://www.googleapis.com/drive/v3/files/1G6N6FyXzg7plgEtJn-Cawo5gbghrS8z9_j_cvVqcEDA";
// and
$url = "https://docs.google.com/document/d/1G6N6FyXzg7plgEtJn-Cawo5gbghrS8z9_j_cvVqcEDA/edit?usp=sharing"
$html= file_get_contents($url);
print_r($html);
A dummy link for anyone willing to help: https://docs.google.com/document/d/1G6N6FyXzg7plgEtJn-Cawo5gbghrS8z9_j_cvVqcEDA/edit?usp=sharing
Since we are getting the URL to the file, we can do a couple of things -
get the id to the file
get what type of file is that
Before I explain how to do that, it is better to know that there can be 2 possible situations. One the file is a google docs file, the other google drive file. Those both start with different URLs.
$url = explode('/', Str::after(
Str::after($request->url, 'https://docs.google.com/'), 'https://drive.google.com/'
));
I am using 2 Str::after() to remove the unnecessary part from the URL. Then I am using explode to convert the URL into an array.
Since we have excluded the useless part from the URL, we are left with document/d/1G6N6FyXzg7plgEtJn-Cawo5gbghrS8z9_j_cvVqcEDA/edit?usp=sharing in an array form.
So, if we try to do $url[2], we get the id of the file. Also, "document" is also a good thing to note about. I use those to show proper images. There can be 5 different types of them (4 for google docs and 1 for google drive). Those are - document, spreadsheets, forms, presentation for google docs, and file for google drive. I would recommend everyone store these in the database so that extra calculations are not necessary while displaying it.
Now, to answer the actual part of the question. How to get the name. I have created a new model method to handle that.
public function name()
{
$key = config('app.google_api_key');
$url = "https://www.googleapis.com/drive/v3/files/{$this->file_id}?key={$key}";
$response = Http::get($url)->json();
return $response['name'] ?? 'Private File';
}
Don't forget to add your Google API key in the config file app.php (You need to create one). You can get your API key from Google Developer Console and create a project-specific key. Just to note that this key need not be belonging to the user of the URL.
Also, a thing to note here is that $response returns error code if the file is not set to visible to the public or the file is deleted.

Webex: How to list hosts meetings

Using PHP I need to get a list of company webex meetings and show them on web page
I tried the code on this page: https://developer.cisco.com/site/webex-developer/develop-test/xml-api/sample-code/
But that failed.
<serv:header>
<serv:response>
<serv:result>FAILURE</serv:result>
<serv:reason>Failed to get SiteUrl</serv:reason>
<serv:gsbStatus>PRIMARY</serv:gsbStatus>
<serv:exceptionID>010000</serv:exceptionID>
</serv:response>
</serv:header>
<serv:body>
Error message was that it could not find the SiteURL. The siteurl I was using is companyname.webex.com - when I put that url into browser, it goes to our webex page, so it seems to be correct.
I found this: http://joshuamcginnis.com/webex/ and tried it (using real credentials), but it gives a 500 error and I have no access to logs.
Both of these examples are very old and I am struggling to find up-to-date examples.
If I put https://company.webex.com/WBXService/XMLService into browser, I get a success message
Can anyone suggest how to do this in either PHP or javascript
According to the PHP example in the link, you must be using something like:
<securityContext>
<webExID>YourCiscoUsername#example.com</webExID>
<password>YourCiscoPassword</password>
<siteID>243585</siteID>
<partnerID>g0webx!</partnerID>
</securityContext>
Try using the "siteName" instead of "siteID", like the following:
<securityContext>
<webExID>YourCiscoUsername#example.com</webExID>
<password>YourCiscoPassword</password>
<siteName>go</siteName>
<partnerID>g0webx!</partnerID>
</securityContext>
You can use siteID or siteName indistinctly, but looks like that siteID isn't working for that demo site right now. Their Java and .Net examples are using siteName.
Now, you have to use "go" in siteName if you are making the request to https://go.webex.com/WBXService/XMLService
But you must use "apidemoeu" if you are making the request to
https://apidemoeu.webex.com/WBXService/XMLService
They both appear to be demo sites.
And effectively "Failed to get SiteUrl" is the error returned if the value passed in either siteName or siteID doesn't correspond to an existing site.

Youtube API V3 - How to get filename from fileDetails

I'm brand new to APIs so please excuse what is probably a long and stupid question. Can I modify this code I got from this sample script - https://developers.google.com/youtube/v3/code_samples/php#update_a_video_by_adding_new_tags - to return the original name of the uploaded file for one of my company's videos? Note: I have already modified the linked script to remove the updating of tags (i.e. I just had it print the video id and the current tags to test that I had the Oauth2 working and I did - so, I got that far at least.)
// Call the API's videos.list method to retrieve the video resource.
$listResponse = $youtube->videos->listVideos("snippet",
array('id' => $videoId));
I was thinking that changing to "snippet" to "fileDetails" is what I need. If so, then how do then extract just the original filename from $listResponse?
Welcome to the world of Google Development. Lets look at the documentation a little for videos.list.
If you check under response you will notice that it returns an array of video resources click on that and the documentation will take you to Videos resource representation as you can see there is lots of fun stuff here. Under snippet you find title.
snippet.title string The video's title. The property value has a
maximum length of 100 characters and may contain all valid UTF-8
characters except < and >. You must set a value for this property if
you call the videos.update method and are updating the snippet part of
a video resource.
On the main videos.list documentation page you will find some examples of how to use it with PHP. Here is a hunk of the first one I think you will like.
// Display the list of matching videos.
foreach ($videosResponse['items'] as $videoResult) {
$videos .= sprintf('<li>%s </li>',
$videoResult['snippet']['title']);
}
Googles documentation is very useful always check it.

Check if Google Map Point is in polygon from PHP

I've been looking for a way to check if a point is part of a polygon; this polygon is loaded from a file.
All the answers related to this question are solved with javascript, but I require to do this on server-side; this because the result does not need to be shown to the user as a webclient, it needs to be stored and later be used as a parameter to select a group of users (that use the system) inside that area (polygon).
I looked for a Google Maps API for PHP but it looks like it does not exists at all. I found this one, but it is not related to Google and also focuses on the front end.
I also looked for a REST API; it would have been relatively easy to load the content to my php and parse it, but looks like Google put all its efforts on the JS API.
Is there any workaround for this?
Edit 1: As #Spacedman requested, the file format is a KML
Clarification 1: I expected that Google provide a tool for this (as it exists with JS); parsing the file to check via an algorithm is a posibility and I'll have to check if it works properly.
Did you try searching for "php point in polygon" in your favourite search engine? Top hit:
http://assemblysys.com/php-point-in-polygon-algorithm/
It uses a scanline algorithm, and there's some examples. All you need to do is read your polygon file into the right format (you neglected to say what format you have) and call the function.
You can try somthing like this (in php should be similar):
int iCheck=0;
for (i = 0, v = HowManyVecotrsHasThePolygon - 1; i < HowManyVecotrsHasThePolygon; v = i++)
{
if (((vectorPointLatitud[i] > ptoLatitud) != (vectorPointLatitud[v] > ptoLatitud)) && (ptoLongitud < (vectorPointLongitud[v] - vectorPointLongitud[i]) * (ptoLatitud - vectorPointLatitud[i]) / (vectorPointLatitud[v] - vectorPointLatitud[i]) + vectorPointLongitud[i]))
iCheck++;
}
if iCheck is pair the point is outside, even inside
Checkout Polygons Eric Haines. I got the idea from him.
The idea is you've to create a Ray from your point, and check how many intersections between this ray and the Polygons vectors
The algorithm is just a bit of algebra, that you can check in any book.
You could use the PHP V8 PECL extension to execute javascript within PHP. Alternatively, you could call a node.js script using a shell command (which essentially does the same thing).
http://php.net/manual/en/book.v8js.php
http://php.net/manual/en/function.shell-exec.php

facebook like button

I have implemented a image gallery where in each image is differentiated by its record id . the like button works properly for rest of images only for two images its not working as intended , this is the post content sent by the image that is working properly
connect_text 0
edge_type like
fb_dtsg AQC7N-EB
href http://www.mydomain.com/images/p.php?id=2422
iframe_referer http://www.mydomain.com/index.php
is_personalized false
layout button_count
lsd
node_type link
now_connected true
page_id
post_form_id 7500ee8867c2d00acc75d7b6dfe2c733
post_form_id_source AsyncRequest
ref
and the facebook response for this is :
for (;;);{"__ar":1,"payload":{"requires_login":false,"error_info":null,"show_error":false,"node_type":"ExternalLink","node_id":"10150246004339081","edge_type":"ExternalLinkLike","connect_text":0,"success":true,"already_connected":true,"user_profile":{"name":"Mamamia","profile_url":"http:\/\/www.facebook.com\/profile.php?id=100002607508082","pic_square":"http:\/\/profile.ak.fbcdn.net\/static-ak\/rsrc.php\/v1\/yo\/r\/UlIqmHJn-SK.gif"},"story_fbid":107571802673069,"is_admin":false,"admin_url":""},"invalidate_cache":[0]}
while for the faulty image post data is
connect_text 0
edge_type like
fb_dtsg AQC7N-EB
href http://www.mydomain.com/images/p.php?id=2420
iframe_referer http://www.mydomain.com/index.php
is_personalized false
layout button_count
lsd
node_type link
now_connected true
page_id
post_form_id 7500ee8867c2d00acc75d7b6dfe2c733
post_form_id_source AsyncRequest
ref
and its response is
for (;;);{"__ar":1,"payload":{"requires_login":false,"success":false,"already_connected":false,"is_admin":false,"show_error":false,"error_info":null}}
can any body tell me why like buttons are working on some images are not working on others t ? the images content is brought from database and is linked in the page by looping the array in foreach condition so hyperlinks are same except for the id of image,the hyperlink is
http://www.facebook.com/plugins/like.php?href=http://www.mydomain.com/images/p.php?id=<?php echo $array[id]; ?>
thanks in advance
Not a proper answer, so sorry for that. But I'm experiencing the same problem exactly. It looks like facebook simply has a problem with certain GET variables in URLs. I can't think of any other explanation, it works for some and not others. The ones it doesn't work for appear to be random.
I think this must be a facebook bug. The only thing I can think to do is to either submit the bug or sit tight and hope they've spotted the problem and are working on it! Pain in the arse, mind.
EDIT: Well, I've got a workaround. Just add a random GET variable to your URL string. I went with 's=true' and that worked. Weird stuff, it must mistake URLs ending in certain numbers as character entities.
I had the same error in my header. It seems the url (domain) did not
pass the validation by facebook. In my case, i had 2 dots in it.
www.somedomain.net16.net (just a working domain)
To see if facebook can retreive data from your site use this url:
http://developers.facebook.com/tools/debug/
To test it, just type www.google.nl and you get all kind of information back.
Use facebook's iframe suggested code which can be obtained here
http://developers.facebook.com/tools/lint/

Categories