Forum in maintenance, we will back soon 🙂
@admin thank you for your answer. I am talking only from the saas course and its codes - not the new course. I will look into it with the ajax testing. I hope this will solve the problem. Thank you for your patience.
@dari-dar no worries friend, we are here to help. Please test and make sure the backend function is working. so we can work on the UI together 🙂
@admin I tried with ajax. The test-tool functions, I get success - see screenshot, but the custom tool has no success. I dont understand why.
 i looked, that i only changed what is allowed to change in the codes from you I used and I cant find the error:
the Tool-Code:
// SEO tool
$seo_tool_config = [
'ENABLE_LOGGING' => false,
'CUSTOM_TOOL_ID' => 70,
'AUTH_REQUIRED' => false,
'POINTS_REQUIRED' => 3,
'ENDPOINT_PATH' => 'seo/google_keyw_rank',
'TOOL_NAME' => "SEO Rank",
'EXPECTED_PARAMS' => [
'keyword' => [
'type' => 'string',
'error_message' => 'keyword not provided.',
]
]
];
custom_lws_tool_setup('custom_tool_seo_test', $seo_tool_config);
Â
Â
here the only thing i changed in the function used by all tools snippet:
function lwh_get_api_key() {
return 'abcdefg'; //
}
function get_custom_tools_api_base_url() {
return "https://hastemp-3137e0496156.herokuapp.com/";
}
Â
in the generic function i didnt change a thing. Did I forget something? Do i have to change something here?:
// Ensure configuration keys exist and assign default values
$ENABLE_LOGGING = array_key_exists('ENABLE_LOGGING', $tool_config) ? $tool_config['ENABLE_LOGGING'] : true;
$CUSTOM_TOOL_ID = array_key_exists('CUSTOM_TOOL_ID', $tool_config) ? $tool_config['CUSTOM_TOOL_ID'] : 0;
$AUTH_REQUIRED = array_key_exists('AUTH_REQUIRED', $tool_config) ? $tool_config['AUTH_REQUIRED'] : false;
$POINTS_REQUIRED = array_key_exists('POINTS_REQUIRED', $tool_config) ? $tool_config['POINTS_REQUIRED'] : 0;
$ENDPOINT_PATH = array_key_exists('ENDPOINT_PATH', $tool_config) ? $tool_config['ENDPOINT_PATH'] : '';
$TOOL_NAME = array_key_exists('TOOL_NAME', $tool_config) ? $tool_config['TOOL_NAME'] : 'Default Tool';
$EXPECTED_PARAMS = array_key_exists('EXPECTED_PARAMS', $tool_config) ? $tool_config['EXPECTED_PARAMS'] : [];
@dari-dar when posting code please use the code icon (<>) above. It keeps the formatting of the code to make it easier to read.
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
@dari-dar, if this is a test website, please send me temporary credentials, I will try to check
@admin do you have an email I can give you admin access to?
I created an account with an email of mine for you. I wrote Access-Data in Discord for https://dari-test.um-web.de/wp-admin
@dari-dar what do you mean by I wrote Access-Data in Discord
anyway, here is my email: hasan@learnwithhasan.com
Hello @admin, I just created an account for you. You should have an email for setting a password on https://dari-test.um-web.de/
I couldn answer earlier. I thought I could write to you in on Discord server, but didnt function.
Finally, I discovered the problem: it is not your fault. It is mine. Everything is working perfectly, but the response coming from your API should have the following JSON structure:
{ "success": true, "message": "Generated Titles Successfully", "result": [ .... ] }
Your api returns:
{ "results": [ .... ] }
Again, I am sorry I didn't clarify that in the course; it took me 2 hours of testing on your site to discover this.Â
Can you please update your API to return the same structure? Adding success and message in your response. Then we can check and continue debugging if it doesn't work.
Â
And I will be working on a more generic approach so you can return any structure you want.
@admin thank you for your response. I changed the code for my api:
@router.get("/seo/google_keyw_rank") async def root(keyword: str, num_results: int = 10, n_pages: int = 1): try: results = [] counter = 0 for page in range(0, n_pages): url = f"https://www.google.com/search?q={keyword}&start={page * 10}" headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' } response = requests.get(url, headers=headers) soup = BeautifulSoup(response.content, "html.parser") search = soup.find_all("div", class_="tF2Cxc") for h in search: if counter == num_results: break counter += 1 title = h.find("h3").text link = h.find("a")["href"] rank = counter htitles = extract_h_titles(link) results.append( { "title": title, "url": link, "rank": rank, "htitles": htitles, } ) if not results: raise HTTPException(status_code=404, detail="No results found") return {"success": True, "message": "Generated Titles Successfully", "result": results } except Exception as e: return {"success": False, "message": str(e), "result": [] }
Â
but unfortunately i still get this when i try:
Test Your AJAX Function Enter your WordPress website URL: https://dari-test.um-web.de/ Enter the AJAX function name: custom_tool_seo_test { "success": false, "message": "Operation failed", "data": null }
Â
i am still looking and trying out to find the problem.
@dari-dar Thanks for the update; now I can continue debugging and checking.
Can I log in again to your site to continue testing?