无法使用pinterest js SDK通过javascript创建pinterest引脚

时间:2018-06-28 14:54:52

标签: javascript pinterest

这是我的代码,我具有访问令牌,可以创建电路板等,但是由于创建引脚而发生错误... 我使用的是官方的pinterest javascript sdk,并且已在我的应用设置中将https://localhost:3000添加到白名单redirect_urls

<script>
           window.pAsyncInit = function() {
               PDK.init({
                   appId: "4974350472186969702", // Change this
                   cookie: true
               });
               var acc = "";
               PDK.login({ scope : 'read_relationships,write_relationships, read_public , write_public' }, function(response){
                   if (!response || response.error) {
                   } else {
                       var pins = [];
                       var fianlData = {};
                       fianlData.data = {};
                       fianlData.access_token = response.session.accessToken;
                       fianlData.data.board = "behzadkhodapanah/ninja2";
                       fianlData.data.note = "label";
                       fianlData.data.link = "https://localhost:3000";
                       fianlData.data.image_url = "https://localhost:3000/image.jpg";
                       console.log("FD : ",fianlData.data);
                       PDK.request('v1/pins/?fields=link%2Cnote%2Curl',fianlData, function (response) {
                           if (!response || response.error) {
                           } else {
                               console.log("JSON : ",JSON.stringify(response));
                               PDK.logout();
                           }
                       });
                   }
               })


           };
           // }
            (function(d, s, id){
                var js, pjs = d.getElementsByTagName(s)[0];
                if (d.getElementById(id)) {return;}
                js = d.createElement(s); js.id = id;
                js.src = "sdk.js";
                pjs.parentNode.insertBefore(js, pjs);
           }(document, 'script', 'pinterest-jssdk'));
        </script>

1 个答案:

答案 0 :(得分:-1)

您可以使用以下代码在pinterest中进行固定请求:

var imgURI =  "image_url";
var note = "note";
var shareURL ="share url";

PDK.pin(imgURI,note,shareURL,function(res){});