Gateway class problems
This is an open discussion with 7 replies, filed under Troubleshooting.
Search
The Gateway class acts a completely separate identity, so doesn't matter if you're logged into Symphony or not because it's essentially like trying to access Symphony from another machine.
I am surprised the ?auth-token
doesn't work though, I'll double check this tonight and see if I can reproduce!
Cheers Brendan, for reference, here's the code.
/** * Calls the preferences page and runs the Resave Entries Extension * @param Array $data */ public function EntryPostEdit($data) { $url_string = '?action[resave]&resave[section]=' . $data['section']->get('id') . '&resave[rate]=50&resave[page]=1&resave[total]=0'; $ch = new Gateway; $ch->init(SYMPHONY_URL . '/system/preferences/' . $url_string); /* $ch->setopt('POST', 1); $ch->setopt('POSTFIELDS', array( 'action' => array('resave'), 'resave' => array( 'section' => $data['section']->get('id'), 'rate' => 50, 'page' => 1, 'total' => 0 ) )); */ $result = $ch->exec(); var_dump($ch, $result);die; }
I'm not 100% sure if the Gateway class acts the same way then curl, but with raw curl, you cannot set arrays on CURLOPT_POSTFIELDS
. You would rather transform the array into a query string like this http_build_query($postData);
Tried that too, and also the same result, hence the $url-string
variable and the commented out code.
My code above is missing the auth-token though, but I did try it.
I've experienced that remote login using auth-token won't work when using other request types than GET and POST. But since you are using POST, this actually should work. Strange…
Yeah, very confusing.
I hope Brendan can shed some light here.
I can't reproduce not being able to see the Preferences page. I'm passing my ?auth-token
(and have it enabled on the Author) and the page is requesting fine.
This is the gist that worked.
Create an account or sign in to comment.
I am trying to use the
Gateway
class in an extension to call the Symphony Preferences page and auto run @alpacaaa's Resave Entries extension on theEntryPostEdit
delegate, and I'm seeing a problem that I can't overcome.Whenever I use the class, the output is always the login page. Quite concerned here, as I am logged in to the site, and the code calling the page is running within Symphony itself, so why would I be directed to the login page?
Also, I've tried passing an
auth-token
in the Gateway request, but that too gets redirected to the login page. I've triedGET
andPOST
too to no avail.Can someone shed some light on this?