Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid_arg_name #2

Open
tryllu opened this issue Nov 5, 2018 · 4 comments
Open

invalid_arg_name #2

tryllu opened this issue Nov 5, 2018 · 4 comments

Comments

@tryllu
Copy link

tryllu commented Nov 5, 2018

Hi,

I have encounter an error when posting through php script running externally.

Following is working when running from cli, as "php slack.php"

<?php
require_once 'app/Mage.php';

Mage::app();
$chat = Mage::getModel('slack/api_chat');
$chat->setChannel('baselinker');
$chat->setText('OK!')->postMessage();

However running same through "curl -X GET url_to_same_file_slack.php" give following error:

Debug:

    [body] => Array
        (
            [ok] =>
            [error] => invalid_arg_name
        )

Exception

Stack trace:
#0 /public_html/app/code/community/Steverobbins/Slack/Model/Api/Abstract.php(117): Mage::throwException('invalid_arg_nam...')
#1 /public_html/app/code/community/Steverobbins/Slack/Model/Api/Chat.php(37): Steverobbins_Slack_Model_Api_Abstract-&gt;__call('postMessage', Array)
#2 /public_html/app/code/community/Steverobbins/Slack/Model/Api/Chat.php(37): Steverobbins_Slack_Model_Api_Abstract-&gt;postMessage()
#3 /public_html/slack.php(7): Steverobbins_Slack_Model_Api_Chat-&gt;postMessage()
#4 {main}
  thrown in <b>/public_html/app/Mage.php</b> on line <b>595</b><br />
@steverobbins
Copy link
Owner

Not sure. Is your cli running the same version of PHP as your webserver?

Can you try logging/var_dump-ing $name, $params in app/code/community/Steverobbins/Slack/Model/Api/Abstract.php:113

@tryllu
Copy link
Author

tryllu commented Nov 5, 2018

Yup. Tried with different php versions of cli.

One more thing, I think it's somehow related to setopts encoding. Of course I will post additional logs.

Funny thing :) When you try to send two messages it also dumps an error. Even from cli.

<?php
require_once 'app/Mage.php';

Mage::app();
$chat = Mage::getModel('slack/api_chat');
$chat->setChannel('baselinker');
$chat->setText('OK1')->postMessage();
$chat->setText('OK2')->postMessage();

But the error is different:

Uncaught Mage_Core_Exception: invalid_array_arg in /public_html/app/Mage.php:595

@tryllu
Copy link
Author

tryllu commented Nov 5, 2018

curl -X GET https://slack.php
Log 1

array(4) {
  ["channel"]=>
  string(9) "hidden"
  ["text"]=>
  string(3) "OK1"
  ["username"]=>
  string(8) "auto_bot"
  ["token"]=>
  string(55) "hidden"
}
<br />
<b>Fatal error</b>:  Uncaught exception 'Mage_Core_Exception' with message 'invalid_arg_name' in /public_html/app/Mage.php:595

@tryllu
Copy link
Author

tryllu commented Nov 5, 2018

Taken with

$params = $this->_prepareParams();
$result = $this->_post($name, $params);
var_dump($name);
var_dump($params);

php56 slack.php

array(4) {
  ["channel"]=>
  string(9) "hidden"
  ["text"]=>
  string(3) "OK1"
  ["username"]=>
  string(8) "auto_bot"
  ["token"]=>
  string(55) "hidden"
}
string(11) "postMessage"
array(5) {
  ["text"]=>
  string(3) "OK2"
  ["username"]=>
  string(8) "auto_bot"
  ["token"]=>
  string(55) "hidden"
  ["ts"]=>
  string(17) "1541457354.002800"
  ["message"]=>
  array(6) {
    ["text"]=>
    string(3) "OK1"
    ["username"]=>
    string(8) "auto_bot"
    ["bot_id"]=>
    string(9) "hidden"
    ["type"]=>
    string(7) "message"
    ["subtype"]=>
    string(11) "bot_message"
    ["ts"]=>
    string(17) "1541457354.002800"
  }
}
PHP Fatal error:  Uncaught exception 'Mage_Core_Exception' with message 'invalid_array_arg' in /public_html/app/Mage.php:595
Stack trace:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants