WooCommerce-REST-API-Client-Library
WooCommerce-REST-API-Client-Library copied to clipboard
Implement WooCommerce REST API into Android app (POST Method)
Hello, I am developing Android Application and using woocommerce REST API i am able to fetch products and display them in android app (with all procedure of signing and authnentication).
But i am not able to create order and customer using POST method in android. I have gone through documentation and all available things but not found something related to POST method in android.
I am getting "404 error". while creating customer order.
Also In PHP i am able to create orders etc ,but same i am not able to achieve in android or in java code.
Please help me to deal with this.
Thank You...
can you please share with us that how have you implemented wc in android.
Thanks for your response....actually now everything is working fine....there was problem with headers in POST method.:)
I am trying to fetch product in json format using rest over http and display them in android. But getting confused how to authentication (authentication and signing procedure). can you please help me to implement authentication and signing to fetch product in json format response. Here is my email add: [email protected] Thanks.
can you please share how you implemented WC in android my mail id is [email protected]
can you please share how you implemented WC in android my mail id is [email protected]
can you please share how you implemented WC in android my mail id is [email protected]
Hi pkhutal, could you please post here your code for implementing WC in android? or maybe you could send it to me, my email is [email protected]. I would appreciate it.
Hi, May I take at look at your code for implementing woocommerce? you can send it in my email [email protected]. Thank you
Could you please tell me how you did it i am trying to build android app for my woocommerce website but have no ideas...please help It would be great if you could send me a code snippet or a demo project email: [email protected]
Thank You
i have problem to fetch data in woocommerce ...i think i cant sign to it.plz help to me [email protected] tnx a lot
I have also issue with customer create api of woocommerce in post method in android.Could you please help me. email: [email protected]
Thank you
I am trying to fetch product in json format using rest over http and display them in android. But getting confused how to authentication (authentication and signing procedure). can you please help me to implement authentication and signing to fetch product in json format response. my email add: [email protected] Thanks.
yes!! this is very simple @kshirsagardeepak @DevSmoo @milon87 you can refer my problem https://github.com/woocommerce/wc-api-php/issues/65 setting up the library & accessing APIs
and also https://github.com/woocommerce/wc-api-php/issues/67 getting JSON output from localhost or anywhere
all you have to do is ..
1st download COMPOSER may be familier with Laravel installation
ok download it .
2nd download wc Rest api Client library rest api unzip it and place it to( htdocs at XAMPP folder)
3rd after installation type 'composer require automattic/woocommerce
' in CMD of requested folder with admin privillages.... in my case i.e. htdocs
4th now you will able to see VENDORS folder in htdocs and also comoposer.json or .lock
now you have to create an index.php file and paste that code you will find on my problem
'require __DIR__ . '/vendor/autoload.php';
use Automattic\WooCommerce\Client;
$woocommerce = new Client(
'http://example.com',
'ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
[
'wp_api' => true,
'version' => 'wc/v1',
]
);'
`try {
// Array of response results.
$results = $woocommerce->get('products');
// Example: ['products' => [[ 'id' => 8, 'created_at' => '2015-05-06T17:43:51Z', 'email' => ...
$json_string = json_encode($results, JSON_PRETTY_PRINT);
\print_r($json_string);
}
`
fire XAMPP localhost you will be able to use your API and JSON output in app or anywhere. good luck with.lv.incals
https://github.com/woocommerce/wc-api-php/issues/65
https://github.com/woocommerce/wc-api-php/issues/67
can you please tell me how you have implemented wc in android its with Volley request or some other third party library. My email id is [email protected]
I also need an example for android App using rest API of a woo commerce website for getting products and their info. All other info also. Please help me get this asap, my mail id: [email protected]
If any one have solution please help me to solve this problem.
Can you please share how you implemented WC Rest API in Android. My email is [email protected]
Could you please tell me how you did it i am trying to build android app for my woocommerce website but have no ideas...please help It would be great if you could send me a code snippet or a demo project email: [email protected]
Thank You
Sorry guys but your savior has come :) Jokes aside I have managed to create resources(specifically coupon and order at this point of time) using java in android after toiling for 2 days. Please check this stackoverflow link and thumbs up and also comment if any doubts.
http://stackoverflow.com/questions/43348471/android-cant-create-order-using-woocommerce-api/43407073#43407073
Could you please tell me how you did it i am trying to build android app for my woocommerce website but have no ideas...please help It would be great if you could send me a code snippet or a demo project email: [email protected]
Thank You
Please check the stackoverflow link.The link is given in my github comment.Also like and accept the answer and if any doubt persists please comment. Thanks.
On Mon, May 15, 2017 at 11:31 PM, SumitDesai [email protected] wrote:
Could you please tell me how you did it i am trying to build android app for my woocommerce website but have no ideas...please help It would be great if you could send me a code snippet or a demo project email: [email protected]
Thank You
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kloon/WooCommerce-REST-API-Client-Library/issues/162#issuecomment-301555224, or mute the thread https://github.com/notifications/unsubscribe-auth/APgx51xDHBEefGao4xymRhlPXEDPVerOks5r6JMNgaJpZM4HgXzn .
Hi,
Can you please send me the java code to create a oauth signature.
Thanks and Regards, Sumit Desai
On Tue, May 16, 2017 at 8:24 AM, debu-Chow [email protected] wrote:
Please check the stackoverflow link.The link is given in my github comment.Also like and accept the answer and if any doubt persists please comment. Thanks.
On Mon, May 15, 2017 at 11:31 PM, SumitDesai [email protected] wrote:
Could you please tell me how you did it i am trying to build android app for my woocommerce website but have no ideas...please help It would be great if you could send me a code snippet or a demo project email: [email protected]
Thank You
— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/kloon/WooCommerce-REST-API-Client- Library/issues/162#issuecomment-301555224>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ APgx51xDHBEefGao4xymRhlPXEDPVerOks5r6JMNgaJpZM4HgXzn> .
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kloon/WooCommerce-REST-API-Client-Library/issues/162#issuecomment-301661230, or mute the thread https://github.com/notifications/unsubscribe-auth/AFFyylme7xidWKXaunfMdhP7agk4EH4zks5r6Q_ggaJpZM4HgXzn .
Hi,
Just try for folling sample: https://github.com/rajatady/Woocommerce-Android-Client might this be helpful.
and get api related help by: https://woocommerce.github.io/woocommerce-rest-api-docs/
Ok I am sending you my code for generating signature in android java.If any doubt please comment.And also if you like,you can upvote my stackoverflow answer so that it can be visible to others as well.(Also will get the "put bounty feature" :)).
client = new InitializeBuilderOkhttp().returnInitializeBuilderOkhttp(); oauthConsumerSecretKeyStringValue = "cs_0b5389fff3d301....ddbdb325fbd64cdc8f4"; oauthConsumerKeyString = "oauth_consumer_key"; oauthConsumerKeyStringValue = "ck_2f53925cb6d2c8f96407.....5f118d01ed80e"; oauthTimestampKeyString = "oauth_timestamp"; oauthTimeStampKeyStringValue = ""; oauthNonceKeyString = "oauth_nonce"; oauthNonceKeyValue = ""; oauthSignatureMethodKey = "oauth_signature_method"; oauthSignatureMethodKeyValue = "HMAC-SHA1"; pageKeyString = "page"; pageKeyValue = getPage; parameterString = ""; urlOrders = "your url.In this case the coupon url."; urlOrdersEncoded = URLEncoder.encode(urlOrders,"utf-8"); Long tsLong = System.currentTimeMillis()/1000; String ts = tsLong.toString(); oauthTimeStampKeyStringValue = ts; oauthNonceKeyValue = randomGenerate();//this is a method to produce a random string of 6 characters.See below. parameterString = URLEncoder.encode(oauthConsumerKeyString,"utf-8")+"="+URLEncoder.encode(oauthConsumerKeyStringValue,"utf-8"); parameterString = parameterString+"&"+URLEncoder.encode(oauthNonceKeyString,"utf-8")+"="+URLEncoder.encode(oauthNonceKeyValue,"utf-8"); parameterString = parameterString+"&"+URLEncoder.encode(oauthSignatureMethodKey,"utf-8")+"="+URLEncoder.encode(oauthSignatureMethodKeyValue,"utf-8"); parameterString = parameterString+"&"+URLEncoder.encode(oauthTimestampKeyString,"utf-8")+"="+URLEncoder.encode(oauthTimeStampKeyStringValue,"utf-8");
parameterStringEncoded = URLEncoder.encode(parameterString,"utf-8"); parameterStringBeforeEncoding = "?"+oauthConsumerKeyString+"="+oauthConsumerKeyStringValue; parameterStringBeforeEncoding = parameterStringBeforeEncoding+"&"+oauthTimestampKeyString+"="+oauthTimeStampKeyStringValue; parameterStringBeforeEncoding = parameterStringBeforeEncoding+"&"+oauthNonceKeyString+"="+oauthNonceKeyValue; parameterStringBeforeEncoding = parameterStringBeforeEncoding+"&"+oauthSignatureMethodKey+"="+oauthSignatureMethodKeyValue;
signatureBaseString = "POST&"+urlOrdersEncoded+"&"+parameterStringEncoded;
Please check the order of the url formed carefully.This is the order to be followed.
Mac mac = null; mac = Mac.getInstance("HMAC-SHA1"); String secret = oauthConsumerSecretKeyStringValue+"&"; mac.init(new SecretKeySpec(secret.getBytes("utf-8"), "HMAC-SHA1")); signature = Base64.encodeToString(mac.doFinal(signatureBaseString.getBytes("utf-8")), 0).trim(); MediaType JSON = MediaType.parse("application/json; charset=utf-8"); JSONObject totalJsonObject = new JSONObject(); JSONObject dataJsonObject = new JSONObject(); dataJsonObject.put("code","asdfas"); totalJsonObject.put("data",dataJsonObject); Log.d("url",""+urlOrders+parameterStringBeforeEncoding+"&oauth_signature="+signature); Log.d("json",""+dataJsonObject.toString()); okhttp3.RequestBody body = RequestBody.create(JSON, postDataString); okhttp3.Request request = new okhttp3.Request.Builder() .url(urlOrders+parameterStringBeforeEncoding+"&oauth_signature="+signature) .post(body) .build();
public static String randomGenerate() { final String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; final int N = alphabet.length();
Random r = new Random();
String outputRandom = "";
for (int i = 0; i < 6; i++) {
outputRandom = outputRandom+alphabet.charAt(r.nextInt(N));
}
return outputRandom;
}
On Tue, May 16, 2017 at 2:11 PM, cool kk [email protected] wrote:
Hi,
Just try for folling sample: https://github.com/rajatady/Woocommerce-Android-Client might this be helpful.
and get api related help by: https://woocommerce.github.io/woocommerce-rest-api-docs/
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kloon/WooCommerce-REST-API-Client-Library/issues/162#issuecomment-301715259, or mute the thread https://github.com/notifications/unsubscribe-auth/APgx58HKWhBEDAC6ahnheBOodq8SKv_Wks5r6WEngaJpZM4HgXzn .
I have also issue with customer create api of woocommerce in post method in android.Could you please help me. email: [email protected]
Thank you
@pkhutal I too have issues with android post methods in c.Please forward the code or library used in android.
Thanks in advance
@pkhutal Hi, I am also trying to connect woocommerce with android but I am getting so confused with the oauth process could you please email me how you did it please? My email is [email protected] Kind regards
hi all can someone send me his android code that can get anything (product list or categorie list ) from WC api here is my email: [email protected]
Thanks in advance
Hello @pkhutal
Can you please share how you implemented WC in android my mail id [email protected]
Thanks