Showing posts with label API. Show all posts
Showing posts with label API. Show all posts
Load Youtube toprated videos using simplexml_load_file PHPView Comments
In this post I will show you how to fetch the you tube top rated videos just with built in PHP functions instead of using zend data api libraries. Zend data api is the best and optimized way to do this task but rather than including and working with zend and zend data api you can just do this with php built-in functions by reading the you tube feeds for the top rated videos.
So here we go. General feed url of youtube is http://gdata.youtube.com/feeds/api/standardfeeds/FEED_IDENTIFIER Youtube feeds URL for the top rated videos is http://gdata.youtube.com/feeds/api/standardfeeds/top_rated Here you can replace top_rated with Fore more info regarding this http://code.google.com/apis/youtube/2.0/developers_guide_php.html So we have to read the feeds from the above url, then you can display it where ever you want. We have the top rated videos as xml so we need to parse it using php function "simplexml_load_file() " . To do this in php.ini we need to enable the url include option to On if it is not already turned on. Get the feeds in a variable $url="http://gdata.youtube.com/feeds/api/standardfeeds/top_rated"; So we have top rated videos in $comments , we need to parse it using foreach and display it in the following way. Here the feed is in yahoo feed format so you to mention the feed as yahoo and then you can parse the media group under entry tag. $media = $video->children('http://search.yahoo.com/mrss/');So from this we can easily parse all the data from the youtube feeds. Download the source for your reference. ![]() You can also do all other functionality like searching a video or displaying particular video comments, recent videos and more using the above method. Its very easier than the zend data api. Try it out. Leave the comments if you have any problem Retrieve Documents List from Google Docs using GData Java Client LibraryView CommentsYou can connect and retrieve data from any of the Google services by using Google API. Here we ![]() If you are using eclipse IDE for working with Java, then the steps of installation are more easy and that can be found in "Coding in the Shade". After successfully installing those libraries and contents. Now we can start developing our first and simple application to retrieve the document list from Google Docs. Now Create a java project and add the necessary External jars to project library. As we are going to develop a application to communicate with Google Docs add the "gdata-docs-3.0.jar" and "gdata-docs-meta-3.0.jar" in specific for this project. Download full Code here In the downloaded code you can find the import statements, which imports three important class to get feeds from Google Docs.
First instance for the DocsSrevice class is created by passing the applications information as parameters to the constructor. And the users credentials such as username with domain name and corresponding password are set using the setUserCredentials() method.
Then the getFeed() method of DocsService class is invoked, the url from which the feeds are to be obtained are passed as the argument. The feeds obtained by getFeed() is assigned to instance of DocumentListFeed. Each entry in the feed are extracted using the DocumentListEntry class.
Then each documents information be obtained as follows:
This is a initiation, you can process a lot more using those API. To get more information about working with Google Docs you can check the following links:
Google Account Authentication using ActionScript in Adobe AIRView Comments
Google Supports developers by providing lots of API for each and every service they provide. By using those APIs, developers can communicate with Google and get feeds from any of thier services by developing a web based application or a installable client application. Before starting to get feeds and post feeds to Google accounts from the application, the developers must get the user's Google account authenticated. To do that user credentials such as email id with password must be send to Google and if the credentials are correct then Google will send back a authorizing token using which developers can start getting feeds and process them.
To authenticate a user, use Google account API, that allow third party application to get limited access to a user's Google accounts for certain types of activities. The Google Authorization Service manages authentication, authorization, and access control to user accounts, subject to approval from the account holder. Google offers several account authorization APIs to accomodate different types of access. Google provides three types of access authorization methods. They are
Download the Full Code First send a http request to Google using HTTPService class with the user name and password by POST. Then scripts must be written to handle the result and failure. Explanation of the code:First all the neccessary information for making a request are set in the HTTPService method. Dont forget to give a valid email and password in the class, otherwise you cannot get authorization. Then the request is send only in the scripting part in the init() function with will be called when application load completes by setting the tag "applicationComplete="init()"". The handlers are already set in the mx tag to handle the result event and failure event. A success response contains the authorization token, labeled "Auth", in the body of the response. Your application must reference this token in each request to the Google service for this user. Additional cookies, labeled "SID" and "LSID", are not currently active and should not be used. A failure response contains an error code and a URL to an error page that can be displayed to the user. Check this links to get still more information from Google:
Subscribe to:
Posts (Atom)
About UsCategories
Followers |