sendText()& _sendDirectItem()& _prepareRecipients()必须是类型数组,给定整数

时间:2018-04-06 21:58:04

标签: php arrays instagram instagram-api

我在日志中收到此错误:

>> arr = ["John", "Jane"]
>> pairs = (1..5).zip(arr.cycle)
#> [[1, "John"], [2, "Jane"], [3, "John"], [4, "Jane"], [5, "John"]]
>> pairs.each { |integer, name| print "#{integer} #{name}\n" }

1 John
2 Jane
3 John
4 Jane
5 John

我认为它来自instagram_helper.php的代码:

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名称(EasyGram)的自动导航脚本。在上次更新开发人员给我新的instagram_helper.php文件,但它无法使用(AutoDirect到新的追随者)。任何想法?

1 个答案:

答案 0 :(得分:1)

替换:

$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)必须是数组。