0

我正在开发 phonegap android 应用程序,在该应用程序中我需要将数据发布到应用程序中的墙中链接。

我正在关注此链接,但它不起作用。

$(document).ready(function(){
var ref = window.open('https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=ntvp5q9iyw8g&scope=w_messages r_network rw_nus r_fullprofile&state=oYyw8xjqR7MLYmYq&redirect_uri=http://oauth://linkedin','_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://oauth://linkedin&client_id=ntvp5q9iyw8g&client_secret=oYyw8xjqR7MLYmYq',
                success: function(a){

                    $.ajax({
                        url : 'https://api.linkedin.com/v1/people/~/shares?oauth2_access_token='+a.access_token,
                        type: 'post',
                        headers : {
                            'Content-Type'  : 'application/json',
                            'x-li-format'   : 'json',
                            'scope'         : 'rw_nus'  
                        },
                        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))
                }
            })
        }
    }
});

});
4

0 回答 0