0

Chrome 拡張機能があり、そのコンテンツ スクリプトはローカル ホストで実行されます

"content_scripts": [{
    "js": ["lib/jquery.js", "searching_helper.js"],
    "matches": [ "http://localhost:8089/*"]
}]

searching_helper.js では、別のコンテンツ スクリプトからリンクされたメンバーのパブリック プロファイル URL を取得しています。

   chrome.runtime.sendMessage({u:true},function(response) {
console.log(response.ans);
linkedinProfileUrl = response.ans.profileUrl;
console.log('linkedinProfileUrl' + linkedinProfileUrl);

});

linkedinProfileUrl 変数では、リンクされたプロファイルが表示されているパブリック プロファイルの URL を取得しています。

今私が欲しいのは、リンクされたAPIを使用しているURLを指定する必要があるサーバー側のコードがあることです。

index.html ファイルのサーバー側コード

  <script type="text/javascript" src="https://platform.linkedin.com/in.js">
//here goes the api key, and the callback function
api_key: ******
onLoad: onLinkedInLoad
authorize: true
 </script>

onload で実行される関数は、linkedin.js ファイルで定義されています。

     function onLinkedInLoad() {
    onLinkedInLogin();

}

    //execute on login event
   function onLinkedInLogin() {
//pass user info to angular
angular.element(document.getElementById("appBody")).scope().$apply(
    function($scope) {
        $scope.getLinkedInData();
    }
);

}

この getLinkedInData() メソッドは controller で定義されています。

    $scope.getLinkedInData = function() {
    if(!$scope.hasOwnProperty("userprofile")){
        IN.API.Profile("https://in.linkedin.com/in/latika").fields(
                [ "id", "firstName", "lastName", "pictureUrl",
                        "publicProfileUrl","positions","location","email-address"]).

この IN.API.Profile(" https://in.linkedin.com/in/latika ") ここで、コンテンツ スクリプトから取得した linkedinProfileUrl を渡したいと思います。問題は、 index.html ファイルにパラメーターを渡すと、エラーがスローされることです。

4

1 に答える 1