GithubHelp home page GithubHelp logo

yos-social-java's Introduction

YOS Social Java SDK has been deprecated. If you have any concerns or questions, please don't hesitate to contact us in General Discussion at YDN forum: https://developer.yahoo.com/forums.

To obtain keys for your YOS application please visit:

http://developer.yahoo.com/dashboard/

================================================================================

To build: Invoke mvn package

================================================================================

Quick start:

  1. Copy yossdk-0.1.0.jar, and dependent jars to WEB-INF/lib
  2. Add com.yahoo.yos.oauth.YahooFilter servlet filter to web.xml, for example:
sample YOSFilter com.yahoo.yos.YahooFilter
    <!-- 
    optional param -
    underlying oauth client class
    possible values:
        net.oauth.client.URLConnectionClient (default)
        net.oauth.client.httpclient3.HttpClient3
        net.oauth.client.httpclient4.HttpClient4
    -->
    <init-param>
        <param-name>oauthConnectionClass</param-name>
        <param-value>net.oauth.client.httpclient4.HttpClient4</param-value>
    </init-param>
    <!-- 
    optional param -
    redirect end-user if an access token is not found, set to false if you 
    are only making two-legged oauth calls e.g. oauth calls without an 
    access token to retrieve public information
    defauts to true
    -->
    <init-param>
        <param-name>redirect</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>

<!--
The URL where the filter is mapped to will redirect the user to Yahoo for
authorization if an OAuth authorization token has not been obtained for the
user.  Should correspond to your callback url
-->

<filter-mapping>
    <filter-name>YOSFilter</filter-name>
    <url-pattern>/login.jsp</url-pattern>
</filter-mapping>
  1. Sample JSP:

<%@ page import="com.yahoo.yos.YahooSession" %><%@ page import="net.oauth.OAuthProblemException" %><%@ page import="org.json.JSONObject" %><% YahooSession state = (YahooSession) request.getAttribute("yahooSession"); if ("POST".equals(request.getMethod())) { String format = request.getParameter("format"); try { if ("yql".equals(request.getParameter("form"))) { String method = request.getParameter("method"); String url = request.getParameter("url"); String callback = request.getParameter("callback"); String query = request.getParameter("query");

            String[] params = null;
            if ("xml".equals(format)) {
                response.setContentType("text/xml");
                params = new String[] {"q", query, "format", format};
            } else {
                response.setContentType("text/plain");
                params = new String[] {"q", query, "format", format, "callback", callback};
            }
            String output = state.invokeString(url, method, params);
            out.println(output);
        } else if ("yap".equals(request.getParameter("form"))) {
            String method = request.getParameter("method");
            String url = request.getParameter("url");
            String content = request.getParameter("content");
            String[] params = {"format", format, "content", content};
            if ("xml".equals(format)) {
                response.setContentType("text/xml");
                out.println(state.invokeStringWithBody(url, method, content, params));
            } else {
                response.setContentType("text/plain");
                JSONObject object = new JSONObject(state.invokeStringWithBody(url, method, content, params));
                out.println("JSON Object:");
                out.println(object.toString(10));
            }
        } else {
            out.println("<html><body>unknown form</body></html>");
        }
    } catch (Exception e) {
        response.setContentType("text/plain");
        e.printStackTrace();
    }
} else if ("GET".equals(request.getMethod()) && "true".equals(request.getParameter("clear"))) {
    state.clearSession(request, response);
} else {

%>

YAP:

logout


Method: GET PUT POST
URL:
Content: <textarea name="content" rows="10" cols="50"> { "status": "Reading paper" } </textarea>
Format: xml json

YQL:

Method: GET PUT POST
URL:
Query:
Format: xml json
Callback:
<% } %>

================================================================================

This project only accepts contributions licensed under the BSD open source license. See the Open Source Initiative's approved template below. Each file submitted should contain the following information in the header:

// Created by [contributor] // Copyright (c) [enter owning person entity, year]. All Rights Reserved. // Licensed under the BSD (revised) open source license.

Here is the Open Source Initiative BSD License Template (http://opensource.org/licenses/bsd-license.php ):


Copyright (c) , All rights reserved.

Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


yos-social-java's People

Contributors

saurabhsahni avatar sh1mmer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.