cordova - Pinterest posting not working inside inappbrowser -


i trying post text , image pinterest using inappbrowser, throwing error "parameter 'image_url' (value http:null) not valid url format."

here sample code.

var pinteresturl = "http://www.pinterest.com/pin/create/button/";      pinteresturl += "?url=https://www.google.co.in/";      pinteresturl += "&media=http://www.google.co.ma/images/srpr/logo1w.png";      pinteresturl += "&description=text description";    var pinterest = window.open(pinteresturl, '_blank'); 

it's working fine in web browser , in system browser (iphone/android) if change code "_blank" "_system". treid inspect url using eventlistener "loadstart" , found inappbrowser automatically adding unnecessary parameters "create next button".

any suggestion helpful.

per our conversation in comments, believe issue no encoding query parameters. encodeuricomponent method used encode special characters when used within queries. encoding entire url not work because of special characters encoded. should encode query parameter values themselves.

var pinteresturl = "http://www.pinterest.com/pin/create/button/"; pinteresturl += "?url=" + encodeuricomponent("https://www.google.co.in/"); pinteresturl += "&media=" + encodeuricomponent("http://www.google.co.ma/images/srpr/logo1w.png"); pinteresturl += "&description=" + encodeuricomponent("text description");    var pinterest = window.open(pinteresturl, '_blank'); 

here way write same thing might little easier read.

function buildurl(baseurl, queryparams) {     return object.keys(queryparams).reduce(function(url, key) {         return key + '=' + encodeuricomponent(queryparams[key]);     }, baseurl + '?'); }  function sharetopinterest() {     var queryparams = {         url: "https://www.google.co.in/",         media: "http://www.google.co.ma/images/srpr/logo1w.png",         description: "text description"     };     var pinteresturl = buildurl("http://www.pinterest.com/pin/create/button/", queryparams);     var pinterest = window.open(pinteresturl, '_blank'); } 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -