sendText() & _sendDirectItem() & _prepareRecipients() 必须是数组类型,整数给定
sendText() & _sendDirectItem() & _prepareRecipients() must be of the type array, integer given
我在日志中收到此错误:
ERROR - 2018-04-07 02:10:23 --> Severity: 4096 --> Argument 1 passed to InstagramAPI\Request\Direct::sendText() must be of the type array, integer given, called in /home/instapanel/public_html/app/helpers/instagram_helper.php on line 5968 and defined /home/instapanel/public_html/app/vendor/mgp25/instagram-php/src/Request/Direct.php 468
ERROR - 2018-04-07 02:10:23 --> Severity: 4096 --> Argument 2 passed to InstagramAPI\Request\Direct::_sendDirectItem() must be of the type array, integer given, called in /home/instapanel/public_html/app/vendor/mgp25/instagram-php/src/Request/Direct.php on line 489 and defined /home/instapanel/public_html/app/vendor/mgp25/instagram-php/src/Request/Direct.php 1002
ERROR - 2018-04-07 02:10:23 --> Severity: 4096 --> Argument 1 passed to InstagramAPI\Request\Direct::_prepareRecipients() must be of the type array, integer given, called in /home/instapanel/public_html/app/vendor/mgp25/instagram-php/src/Request/Direct.php on line 1132 and defined /home/instapanel/public_html/app/vendor/mgp25/instagram-php/src/Request/Direct.php 928
我认为它来自 instagram_helper.php 的代码:
if (!empty($users))
{
foreach($users as $user)
{
if (!empty($user))
{
$info = $i->people->getFriendship($user->id);
if ($info->status == "ok")
{
$history = $CI->db->select("*")->where("pk", $user->username)->where("type", $data->category)->where("account_id", $data->account_id)->get(INSTAGRAM_HISTORY)->row();
if (empty($history) && $info->following == "" && $info->outgoing_request == "" && $info->followed_by == 1)
{
$follow = $i->people->follow($user->id);
// echo "<a href='https://instagram.com/".$user->username."' target='_blank'>".$user->username."</a>";
if ($follow->status == "ok")
{
$messages = (array)json_decode($data->message);
$message_index = array_rand((array)json_decode($data->message));
if (!empty($messages))
{
$message = $spintax->process($messages[$message_index]);
if ($message != "")
{
$mess = $i->direct->sendText($user->id, $message);
}
}
$user->pk = $user->id;
$response = array(
"st" => "success",
"data" => json_encode($user) ,
"code" => $user->username,
"txt" => l('Successfully')
);
}
break;
}
}
}
}
}
此代码来自 Instagram 名称 (EasyGram) 的自动驾驶脚本。在上次更新中,开发人员给我新的 instagram_helper.php 文件,但它不适用于(AutoDirect 到新关注者)。有什么想法吗?
替换:
$mess = $i->direct->sendText($user->id, $message);
和
$mess = $i->direct->sendText([$user->id], $message);
查看源码可以看到:
/**
* Send a direct text message to a user's inbox.
*
* @param array $recipients An array with "users" or "thread" keys.
* To start a new thread, provide "users" as an array
* of numerical UserPK IDs. To use an existing thread
* instead, provide "thread" with the thread ID.
* @param string $text Text message.
* @param array $options An associative array of optional parameters, including:
* "client_context" - predefined UUID used to prevent double-posting.
*
* @throws \InvalidArgumentException
* @throws \InstagramAPI\Exception\InstagramException
*
* @return \InstagramAPI\Response\DirectSendItemResponse
*/
public function sendText(
array $recipients,
$text,
array $options = [])
第一个参数 ($recipients) 必须是一个数组。
我在日志中收到此错误:
ERROR - 2018-04-07 02:10:23 --> Severity: 4096 --> Argument 1 passed to InstagramAPI\Request\Direct::sendText() must be of the type array, integer given, called in /home/instapanel/public_html/app/helpers/instagram_helper.php on line 5968 and defined /home/instapanel/public_html/app/vendor/mgp25/instagram-php/src/Request/Direct.php 468
ERROR - 2018-04-07 02:10:23 --> Severity: 4096 --> Argument 2 passed to InstagramAPI\Request\Direct::_sendDirectItem() must be of the type array, integer given, called in /home/instapanel/public_html/app/vendor/mgp25/instagram-php/src/Request/Direct.php on line 489 and defined /home/instapanel/public_html/app/vendor/mgp25/instagram-php/src/Request/Direct.php 1002
ERROR - 2018-04-07 02:10:23 --> Severity: 4096 --> Argument 1 passed to InstagramAPI\Request\Direct::_prepareRecipients() must be of the type array, integer given, called in /home/instapanel/public_html/app/vendor/mgp25/instagram-php/src/Request/Direct.php on line 1132 and defined /home/instapanel/public_html/app/vendor/mgp25/instagram-php/src/Request/Direct.php 928
我认为它来自 instagram_helper.php 的代码:
if (!empty($users))
{
foreach($users as $user)
{
if (!empty($user))
{
$info = $i->people->getFriendship($user->id);
if ($info->status == "ok")
{
$history = $CI->db->select("*")->where("pk", $user->username)->where("type", $data->category)->where("account_id", $data->account_id)->get(INSTAGRAM_HISTORY)->row();
if (empty($history) && $info->following == "" && $info->outgoing_request == "" && $info->followed_by == 1)
{
$follow = $i->people->follow($user->id);
// echo "<a href='https://instagram.com/".$user->username."' target='_blank'>".$user->username."</a>";
if ($follow->status == "ok")
{
$messages = (array)json_decode($data->message);
$message_index = array_rand((array)json_decode($data->message));
if (!empty($messages))
{
$message = $spintax->process($messages[$message_index]);
if ($message != "")
{
$mess = $i->direct->sendText($user->id, $message);
}
}
$user->pk = $user->id;
$response = array(
"st" => "success",
"data" => json_encode($user) ,
"code" => $user->username,
"txt" => l('Successfully')
);
}
break;
}
}
}
}
}
此代码来自 Instagram 名称 (EasyGram) 的自动驾驶脚本。在上次更新中,开发人员给我新的 instagram_helper.php 文件,但它不适用于(AutoDirect 到新关注者)。有什么想法吗?
替换:
$mess = $i->direct->sendText($user->id, $message);
和
$mess = $i->direct->sendText([$user->id], $message);
查看源码可以看到:
/**
* Send a direct text message to a user's inbox.
*
* @param array $recipients An array with "users" or "thread" keys.
* To start a new thread, provide "users" as an array
* of numerical UserPK IDs. To use an existing thread
* instead, provide "thread" with the thread ID.
* @param string $text Text message.
* @param array $options An associative array of optional parameters, including:
* "client_context" - predefined UUID used to prevent double-posting.
*
* @throws \InvalidArgumentException
* @throws \InstagramAPI\Exception\InstagramException
*
* @return \InstagramAPI\Response\DirectSendItemResponse
*/
public function sendText(
array $recipients,
$text,
array $options = [])
第一个参数 ($recipients) 必须是一个数组。