How to text a LinkedIn wall on PhoneGap?

I am developing one app in PhoneGap in this app that I want to share a text message to Facebook, twitter and LinkedIn. for ANDROID-LinkedIn I search many google links but I get good results. please help me i am amazed here.

I am implementing this example:

<html>
    <head>
        <title>OAuthSimple w/ LinkedIn</title>
        <script src="OAuthSimple.js"></script>
        <script>
            /*
                You must edit the two following lines and put in your consumer key and shared secret
            */
            var consumer_key = "ibmay1qostgk";
            var shared_secret = "4HqeDRZ2ZKAvASlM";

            /*
                Nothing below here needs to be edited for the demo to operate
            */

            var oauth_info = {};
            var oauth = OAuthSimple(consumer_key, shared_secret);

            function parse_response(response, callback) 
            {
                response.replace(new RegExp("([^?=&]+)(=([^&]*))?", "g"), function($0, $1, $2, $3) { oauth_info[$1] = $3; });
                callback.call();
            }

            function authorize_url() 
            34{
                set_url("https://www.linkedin.com/uas/oauth/authenticate?oauth_token=" + oauth_info.oauth_token, document.getElementById("au"));
            }

            function access_token_url(pin) {
                oauth.reset();      
                var url = oauth.sign({action: "GET", path: "https://api.linkedin.com/uas/oauth/accessToken", parameters: {oauth_verifier: pin}, signatures: oauth_info}).signed_url;

                set_url(url, document.getElementById("at"));
            }

            function fetch_profile_url() {
                oauth.reset();  

                var url = oauth.sign({action: "GET", path: "https://api.linkedin.com/v1/people/~", signatures: oauth_info}).signed_url;

                set_url(url, document.getElementById("fp"));
            }

            function set_url(url, element) {
                element.value = url;

                var span = document.createElement("span");
                span.innerHTML = "&nbsp;&nbsp;<a href='" + url + "' target='_blank'>Open</a>";
                element.parentNode.insertBefore(span, element.nextSibling);
            }

            window.onload = function() {
                var url = oauth.sign({action: "GET", path: "https://api.linkedin.com/uas/oauth/requestToken", parameters: {oauth_callback: "oob"}}).signed_url;

                set_url(url, document.getElementById("rt"));
            }
        </script>
    </head>
    <body>
        <h1>OAuthSimple w/ LinkedIn</h1>
        <label for="rt">Request Token URL:</label> <input type="text" size="100" name="rt" id="rt" >
        <br><br>
        <label for="rtr">Request Token Response:</label><br><textarea rows="5" cols="75" name="rtr" id="rtr"></textarea>
        <br>
        <button onclick="javascript:parse_response(document.getElementById('rtr').value, authorize_url)">Parse Response</button>
        <br><br>
        <label for="au">Authorize URL:</label> <input type="text" size="100" name="au" id="au">
        <br><br>
        <label for="vp">Verifier PIN Code:</label> <input type="text" size="100" name="vp" id="vp">
        <button onclick="javascript:access_token_url(document.getElementById('vp').value)">Get Access Token URL</button>
        <br><br>
        <label for="at">Access Token URL:</label> <input type="text" size="100" name="at" id="at">
        <br><br>
        <label for="atr">Access Token Response:</label><br><textarea rows="5" cols="75" name="atr" id="atr"></textarea>
        <br>
        <button onclick="javascript:parse_response(document.getElementById('atr').value, fetch_profile_url)">Parse Response</button>
        <br><br>
        <label for="fp">Fetch Profile URL:</label> <input type="text" size="100" name="fp" id="fp">
    </body>
</html>

      

early

+3


source to share


1 answer


Here is a complete example of logging in and sending msg linkedIn using Phonegap



ref = window.open('https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=APIKEY&scope=w_messages r_network r_emailaddress r_fullprofile&state=APISECRET&redirect_uri=SOMEACTIVESITE','_blank','location=no');
    ref.addEventListener('loadstart', function(e){
        $.mobile.loading( 'show' );
        if(e.url.indexOf('?code=') >=0 ){
            if(e.url.match(/=[^]+&/)){
                var code = e.url.match(/=[^]+&/)[0].substring(1).replace('&','');
                window.sessionStorage.setItem('code', code);
                ref.close();

                $.ajax({
                    url: 'https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code='+code+'&redirect_uri=http://janbeeangeles.com&client_id=jwwwdjplwubu&client_secret=ygMy3EpVcs6IAORE',
                    success: function(a){

                        $.ajax({
                            url : 'https://api.linkedin.com/v1/people/~/mailbox?oauth2_access_token='+a.access_token,
                            type: 'post',
                            headers : {
                                'Content-Type'  : 'application/json',
                                'x-li-format'   : 'json'
                            },
                            data: JSON.stringify({
                              "recipients": {
                                "values": [
                                {
                                  "person": {
                                    "_path": "/people/~",
                                   }
                                }]
                              },
                              "subject": "asdasdasd on your new position.",
                              "body": "You are certainly the best person for the job!"
                            }),
                            success: function(a){
                                alert(2222)
                            },
                            error: function(a){
                                alert(JSON.stringify(a))
                            }
                        })
                    },
                    error: function(a){
                        alert(JSON.stringify(a))
                    }
                })
            }
        }
    });

      

+3


source







All Articles