如何使用asp.net中的javascript API在Linkedin上发布带有标题的图像

如何使用asp.net中的javascript API在Linkedin上发布带有标题的图像,javascript,asp.net,Javascript,Asp.net,如何使用asp.net中的javascript API在Linkedin上发布带有标题的图像 function shareContent() { // Build the JSON payload containing the content to be shared //var payload = { // "comment": "Check out developer.linkedin.com", // "visibility": { /

如何使用asp.net中的javascript API在Linkedin上发布带有标题的图像

function shareContent() {

    // Build the JSON payload containing the content to be shared
    //var payload = {
    //    "comment": "Check out developer.linkedin.com",
    //    "visibility": {
    //        "code": "anyone"
    //    }
    //};

    IN.API.Raw("/people/~/shares?format=json")
      .method("POST")
      .body(JSON.stringify("Test123456"))
      .result(function error(e) { alert("Success") })
      .error(function error(e) { alert("No dice") });

}


IN.API.RAW()给出了未定义IN.API的错误

请看一下我的项目以及我是如何使用jssdk的,因为我所做的一些事情与您试图解决的问题非常相似

以下是其中一个文件中可能涉及的片段:

$(document).ready(function(){

$("#submit_button").click(function organizeinput(){
    if (IN.User.isAuthorized() == true){
var values = new Array();
//comment, title, description, image-content, image-url
// Get the parameters as an array
values = $(":input").serializeArray();
// Find and replace `content` if there
var countinput=0;
for (index = 0; index < values.length; ++index) 
    {
        if (values[index].name == "comment" && values[index].value != "") 
        {
            var comment;
            comment = values[index].value;
            countinput=countinput+1;
        }
        if (values[index].name == "title" && values[index].value != "") 
        {
            var title;
            title = values[index].value;
            countinput=countinput+1;
        }
        if (values[index].name == "description" && values[index].value != "") 
        {
           var description;
           description = values[index].value;
           countinput=countinput+1;
        }
        if (values[index].name == "image-content" && values[index].value != "") 
        {
            var imagecontent;
            imagecontent = values[index].value;
            countinput=countinput+1;
        }
        if (values[index].name == "image-url" && values[index].value != "") 
        {
            var imageurl;
            imageurl = values[index].value;
            countinput=countinput+1;
        }
    }   

if (countinput == 5){
var postcontent = new Array();
postcontent = {"comment": comment, "content": {"title": title,"description": description,"submitted-url": imagecontent,"submitted-image-url": imageurl},"visibility": {"code": "anyone"} };
postcontent = JSON.stringify(postcontent);

shareContent(postcontent);
}
else alert("All the fields are required.");
}
else alert("You have to login to linkedin before you can post content.");
});


function onLinkedInLoad() {
      IN.Event.on(IN, "auth", organizeinput);
    }

  // Handle the successful return from the API call
  function onSuccess(data) {
    console.log(data);
    alert("Post Successful!");
  }

  // Handle an error response from the API call
  function onError(error) {
    console.log(error);
    alert("Oh no, something went wrong. Check the console for an error log.");
  }

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

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

});
$(文档).ready(函数(){
$(“#提交按钮”)。单击(函数organizeinput(){
if(IN.User.isAuthorized()==true){
var值=新数组();
//注释、标题、描述、图像内容、图像url
//以数组的形式获取参数
值=$(“:输入”).serializeArray();
//查找并替换“content”(如果有)
var countinput=0;
对于(索引=0;索引