Need help in porting Java code to PHP -


i need develop marketplace api orders , post shipping walmart in php. code library/help sample provided in java. not java.

need understanding / coding in php. here code in java. link api developers guide https://developer.walmartapis.com/#self-written-code-expert

this app on cpanel server.

import org.apache.commons.codec.binary.base64; import java.security.keyfactory; import java.security.privatekey; import java.security.signature; import java.security.spec.pkcs8encodedkeyspec;  public class sha256withrsaalgo { private static string consumerid = "b68d2a72....";   // trimmed security reason private static string baseurl = "https://marketplace.walmartapis.com/v2/feeds"; private static string privateencodedstr = "miiceaibadanbgkqhkig9w0baqefaa......";       //trimmed security reasons public static void main(string[] args) {     string httpmethod = "get";     string timestamp = string.valueof(system.currenttimemillis());     string stringtosign = consumerid + "\n" +                             baseurl + "\n" +                             httpmethod + "\n" +                             timestamp + "\n";     string signedstring = sha256withrsaalgo.signdata(stringtosign, privateencodedstr);     system.out.println("signed string: " + signedstring); } public static string signdata(string stringtobesigned, string encodedprivatekey) {     string signaturestring = null;     try {         byte[] encodedkeybytes = base64.decodebase64(encodedprivatekey);         pkcs8encodedkeyspec privspec = new pkcs8encodedkeyspec(encodedkeybytes);         keyfactory kf = keyfactory.getinstance("rsa");         privatekey myprivatekey = kf.generateprivate(privspec);         signature signature = signature.getinstance("sha256withrsa");         signature.initsign(myprivatekey);         byte[] data = stringtobesigned.getbytes("utf-8");         signature.update(data);         byte[] signedbytes = signature.sign();         signaturestring = base64.encodebase64string(signedbytes);     } catch (exception e) {         e.printstacktrace();     }     return signaturestring; } } 

edit:

the part did not understand #3 on page. says sign byte array representation of data by

https://developer.walmartapis.com/#self-written-code-expert

it's quite simple actually, java imports packages each source file php include files. first lines doing , classes function pretty php5 classes. that's it. specifying don't understand better explaining code...


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -