data:
array {
foo: bar,
bar: foo
array {
foo: bar,
bar:foo
}
}
Error: call to URL http://xenforo.com/api/license-lookup.json failed with status 200, response {"error":["Please enter a validation token."],"templateHtml":"\n\n
\n\t<\/a>\n\t\n\t\t
The following error occurred<\/h2>\n\t\t\n\t\t
\n\t\t\n\t\t\tPlease enter a validation token.<\/label>\n\t\t\n\t\t<\/div>\n\t\n<\/div>"}, curl_error , curl_errno 0
array(2) {
["error"] => array(1) {
[0] => string(83) "This action is available via POST only. Please press the back button and try again."
}
["templateHtml"] => string(312) "
<div class="errorOverlay">
<a class="close OverlayCloser"></a>
<h2 class="heading">The following error occurred</h2>
<div class="baseHtml">
<label for="ctrl_0" class="OverlayCloser">This action is available via POST only. Please press the back button and try again.</label>
</div>
</div>"
}
public static function license()
{
$options = XenForo_Application::get('options');
$db = XenForo_Application::get('db');
$client = XenForo_Helper_Http::getClient('http://xenforo.com/api/license-lookup.json');
$users = $db->query("SELECT * FROM `xf_user` WHERE token_valid = 0");
foreach ($users AS $user)
{
$client->setParameterGet('token', $user['token'], 'domain', $user['domain']);
$response = $client->request('POST');
$new = json_decode($response->getBody(), true);
if ($new)
{
$db->update('xf_user',
array('token' => $new['license_token'], 'token_valid' => '1'),
'user_id = 1'
);
}
}
}
There's ways around that but quite simply you could just set up a new controller action somewhere so you can access the URL and run the code on demand. It will then render the output you might need to see for debugging purposes.Yeah see I can't see that when running a cron for some reason.
or I'm just constructing this all wrong.
$users = $db->query("SELECT * FROM `xf_user`");
$users = $db->fetchAll("SELECT * FROM `xf_user`");
Server Error
Undefined index: license_token
$options = XenForo_Application::get('options');
$db = XenForo_Application::get('db');
$client = XenForo_Helper_Http::getClient('http://xenforo.com/api/license-lookup.json');
$users = $db->fetchAll("SELECT * FROM `xf_user`");
foreach ($users AS $user)
{
$client->setParameterPost('token', $user['token'], 'domain', $user['domain']);
$response = $client->request('POST');
$new = json_decode($response->getBody(), true);
if (!empty($new['license_token']))
{
$db->update('xf_user',
array('token' => $new['license_token'], 'token_valid' => '1'),
'user_id = 1'
);
}
}
We use essential cookies to make this site work, and optional cookies to enhance your experience.