Jump to content

php doesn't execute unless loaded in browser


Barry
 Share

Recommended Posts

I have a page with a template that is purely intended for carrying out php tasks.

This page/url is called when certain objects in SalesForce are saved. The URL is called with a few GET variables.

To make sure that the URL with the GET variables is called, I write them to a log, and this works fine, except the php and ProcessWire code I've written doesn't execute.

Only once I visit the exact same URL that was written to the log in my browser, then the php and ProcessWire code executes perfectly, no errors.

I can't see any reason for this, and I'm not sure what to search for in order to sort this out. Can anyone give any ideas?

Link to comment
Share on other sites

PHP is a server-side scripting language, and sends the data to the client on page load. To get the script to run without a page view, you would need to set up a cron job. Cron jobs are used for scheduling tasks/scripts to run on the server. If you are using shared hosting, there is normally a tool  in the control panel for setting up and managing cron jobs.

 

Link to comment
Share on other sites

sorry, my original post may not be clear:

$contact = $pages->get("salesforce_id^=$sfid");
$location = $pages->get("template='pageLocation', contact=[salesforce_id^='$sfid']");

the top line $contact returns a processwire ID whether the URL is called by salesforce or by my browser.

$location does not return anything when salesforce calls it but returns a processwire ID when I call the URL in my browser.

Link to comment
Share on other sites

30 minutes ago, Barry said:

$location does not return anything when salesforce calls it but returns a processwire ID when I call the URL in my browser.

Were you logged in to the backend when it worked? If yes, you might have a permissions issue.

Link to comment
Share on other sites

No, being logged in or not makes no difference. These two lines of code run at the same time. It just seems like a nested selector won't work unless the page is viewed in a browser.

I've managed to get it working with the following:

$contact = $pages->get("salesforce_id^=$sfid");
$location = $pages->get("template='pageLocation', contact=$contact");

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...