Прежде всего, я проверил десятки результатов поиска, включая пару статей StackOverflow по этой теме - и нет, похоже, никто не ответил на него (хотя сам вопрос может показаться похожим на некоторые извы)
Подводя итог проблемы: При вызове публичной функции вне класса / вызове метода я получаю следующую ошибку: 'Вызов неопределенной функции ...'
<?php
use InstagramAPI\Exception\ChallengeRequiredException;
use InstagramAPI\Instagram;
use InstagramAPI\Response\LoginResponse;
use InstagramAPI\Exception\RequestHeadersTooLargeException;
use InstagramAPI\Exception\ThrottledException;
use InstagramAPI\Utils;
require_once __DIR__ . '/vendor/autoload.php';
$username = "name";
$password = "password";
$ig = new \InstagramAPI\Instagram();
try {
$ig->login($username, $password);
} catch (\Exception $e) {
echo 'Something went wrong: '.$e->getMessage()."\n";
exit(0);
}
class RequestCollection
{
/** @var Instagram The parent class instance we belong to. */
public $ig;
/**
* Constructor.
*
* @param Instagram $parent The parent class instance we belong to.
*/
public function __construct(
$parent)
{
$this->ig = $parent;
}
/**
* Paginate the request by given exclusion list.
*
* @param Request $request The request to paginate.
* @param array $excludeList Array of numerical entity IDs (ie "4021088339")
* to exclude from the response, allowing you to skip entities
* from a previous call to get more results.
* @param string|null $rankToken The rank token from the previous page's response.
* @param int $limit Limit the number of results per page.
*
* @throws \InvalidArgumentException
*
* @return Request
*/
protected function _paginateWithExclusion(
Request $request,
array $excludeList = [],
$rankToken = null,
$limit = 30)
{
if (!count($excludeList)) {
return $request->addParam('count', (string) $limit);
}
if ($rankToken === null) {
throw new \InvalidArgumentException('You must supply the rank token for the pagination.');
}
Utils::throwIfInvalidRankToken($rankToken);
return $request
->addParam('count', (string) $limit)
->addParam('exclude_list', '['.implode(', ', $excludeList).']')
->addParam('rank_token', $rankToken);
}
/**
* Paginate the request by given multi-exclusion list.
*
* @param Request $request The request to paginate.
* @param array $excludeList Array of grouped numerical entity IDs (ie "users" => ["4021088339"])
* to exclude from the response, allowing you to skip entities
* from a previous call to get more results.
* @param string|null $rankToken The rank token from the previous page's response.
* @param int $limit Limit the number of results per page.
*
* @throws \InvalidArgumentException
*
* @return Request
*/
protected function _paginateWithMultiExclusion(
Request $request,
array $excludeList = [],
$rankToken = null,
$limit = 30)
{
if (!count($excludeList)) {
return $request->addParam('count', (string) $limit);
}
if ($rankToken === null) {
throw new \InvalidArgumentException('You must supply the rank token for the pagination.');
}
Utils::throwIfInvalidRankToken($rankToken);
$exclude = [];
$totalCount = 0;
foreach ($excludeList as $group => $ids) {
$totalCount += count($ids);
$exclude[] = "\"{$group}\":[".implode(', ', $ids).']';
}
return $request
->addParam('count', (string) $limit)
->addParam('exclude_list', '{'.implode(',', $exclude).'}')
->addParam('rank_token', $rankToken);
}
}
class People extends RequestCollection
{
public function getInfoByName(
$username,
$module = 'feed_timeline')
{
return $this->ig->request("users/{$username}/usernameinfo/")
->addParam('from_module', $module)
->getResponse(new Response\UserInfoResponse());
}
}
getInfoByName("testuser")
//echo setCloseFriends(["Versaute.Witze", "Instagram"], ["leonie.kai"]);
//$ig->people->setCloseFriends($add = $addinput, $remove = $removeinput, $module = 'favorites_home_list', $source = 'audience_manager');
?>
Проблема заключается в функции getInfoByName, которая, очевидно, не может быть вызвана. Я имею в виду представителя GitHub - mgp25 / Instagram-API.