解析JSON字符串值

时间:2016-05-30 07:26:36

标签: javascript json

我有一个大问题,希望有人能帮我解决。我正在尝试从API中创建一个Linkedin共享功能。 JSON中的内容在LinkedIn上非常完美。但问题是,一个人无法看到发布框中发布的内容。我上传了我的分享按钮到我的域名,如果有人想测试它:

  

http://www.vouzalis.com/wwwroot/stackTest.html

在我看来,我做了API所要求的一切:

  

https://developer.linkedin.com/docs/share-on-linkedin

我看不出还有什么我想念的?有没有人知道可能有什么问题?

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8" />
    <script type="text/javascript" src="http://platform.linkedin.com/in.js">
        api_key: myAPIKey
        authorize: true
        onLoad: onLinkedInLoad
        lang : da_DK
    </script>



</head>
<body>

    <script type="in/Share">
    </script>

    <script>
        // Setup an event listener to make an API call once auth is complete
        function onLinkedInLoad() {
            IN.Event.on(IN, "auth", shareContent);
        }

        // Handle the successful return from the API call
        function onSuccess(data) {
            console.log(data);
        }

        // Handle an error response from the API call
        function onError(error) {
            console.log(error);
        }

        // Use the API call wrapper to share content on LinkedIn
        function shareContent() {

            // Build the JSON payload containing the content to be shared
            var payload = {
                "comment": "Check this awesome website out",
                "content":  {
                    "title": "Hello",
                    "description": "StackOverflow",
                    "submitted-url": "https://www.stackoverflow.com",
                    "submitted-image-url": "http://i.telegraph.co.uk/multimedia/archive/03597/POTD_chick_3597497k.jpg"
                },
                "visibility":  {
                    "code": "anyone"
                }
            }

            IN.API.Raw("/people/~/shares?format=json")
            .method("POST")
            .body(JSON.stringify(payload))
            .result(onSuccess)
            .error(onError);
        };


    </script>

</body>
</html>

0 个答案:

没有答案