How to add categories or sub-categories via API?

Post: http://www.namedoseusite.com.br/api_categories.php?action=add_categories









Parameter format description
categories_Name json

categorie or sub-categorie name
Format: Varchar (255)
* Field Required

categories_status json 1 = Active or 0 = Inactive
Only Number is Required
Format: int (1)
* Field Required
main_category json Main Category of sub-category
Only Number is Required
Check the api to get the id of the categories or sub-categories
format: int (11)
** Field Required
sort_order json Sort Order
Only Number is Required
Format: int (3)
meta_title json Title goal
Format: Text
Meta_Description json Goal Description
Format: Text
meta_keywords json Meta Keywords
Format: Text

php sample

 // sample add categories and sub-categories

$ URL = $ tabain_url. ' /api_categories.php? Action = add_categories ' ;;

$ data = array ("categories_name" = & gt; "categorie or sub-categorie name", // categorie or sub-categorie name * Field Required
"categories_status" = & gt; "1", // 1 = active or 0 = inactive (Only Number is Required) * Field Required
"main_category" = & gt; "0", // main category of sub-category (Only Number is Required) * Field Required
"Sort_order" = & gt; "", // Sort Order (Only Number Is Required)
"meta_title" = & gt; "Meta Title", // Meta Title
"Meta_Description" = & gt; "Meta Description", // Goal Description
"meta_keywords" = & gt; "Meta Keywords"
);

$ data_string = json_encode ($ date);

$ CH = curl_init ($ URL);
Curl_Setopt ($ CH, curlopt_customrequest, "post");
Curl_Setopt ($ CH, Curlopt_postFields, $ Data_String);
Curl_Setopt ($ CH, Curlopt_Returntransfer, True);
curl_setopt ($ CH, curlopt_ssl_verifypeer, false);
Curl_Setopt ($ CH, Curlopt_httpheader, Array (
' CONTENT-TYPE: Application/JSON ',
"Cache-Control: No-Cache",
' Usuario1: ' . base64_encode ($ Usuario1),
' password1: ' . base64_encode ($ password1),
' CONTENT-LENGTH: ' . Strlen ($ data_string)))
);

$ result = curl_exec ($ CH);
Curl_Close ($ CH);

print_r ($ result);

// sample add categories and sub-categories eof

Return Error:

Code
Message

Return Success:

Code
ID
Message

Leave a Reply 0