【问题标题】:PHP autoload.php not foundPHP autoload.php 未找到
【发布时间】:2018-02-21 17:16:23
【问题描述】:

这是我的代码:

<?php
echo 'hey1';
set_time_limit(0);
date_default_timezone_set('UTC');
echo 'hey2';
require __DIR__.'/../vendor/autoload.php';
echo 'hey3';
/////// CONFIG ///////
$username = 'NetsGets';
$password = 'NetsGetsWebsite';
$debug = true;
$truncatedDebug = false;
//////////////////////

$ig = new \InstagramAPI\Instagram($debug, $truncatedDebug);

try {
    $ig->login($username, $password);
} catch (\Exception $e) {
    echo 'Something went wrong: '.$e->getMessage()."\n";
    exit(0);
}

try {
    $feed = $ig->discover->getExploreFeed();

    // Let's begin by looking at a beautiful debug output of what's available in
    // the response! This is very helpful for figuring out what a response has!
    $feed->printJson();

    // Now let's look at what properties are supported on the $feed object. This
    // works on ANY object from our library and will show what functions and
    // properties are supported, as well as how to call the functions! :-)
    $feed->printPropertyDescriptions();

    // The getExploreFeed() has an "items" property, which we need. As we saw
    // above, we should get it via "getItems()". The property list above told us
    // that it will return an array of "Item" objects. Therefore it's an ARRAY!
    $items = $feed->getItems();

    // Let's get the media item from the first item of the explore-items array...!
    $firstItem = $items[0]->getMedia();

    // We can look at that item too, if we want to... Let's do it! Note that
    // when we list supported properties, it shows everything supported by an
    // "Item" object. But that DOESN'T mean that every property IS available!
    // That's why you should always check the JSON to be sure that data exists!
    $firstItem->printJson(); // Shows its actual JSON contents (available data).
    $firstItem->printPropertyDescriptions(); // List of supported properties.

    // Let's look specifically at its User object!
    $firstItem->getUser()->printJson();

    // Okay, so the username of the person who posted the media is easy... And
    // as you can see, you can even chain multiple function calls in a row here
    // to get to the data. However, be aware that sometimes Instagram responses
    // have NULL values, so chaining is sometimes risky. But not in this case,
    // since we know that "user" and its "username" are always available! :-)
    $firstItem_username = $firstItem->getUser()->getUsername();

    // Now let's get the "id" of the item too!
    $firstItem_mediaId = $firstItem->getId();

    // Finally, let's get the highest-quality image URL for the media item!
    $firstItem_imageUrl = $firstItem->getImageVersions2()->getCandidates()[0]->getUrl();

    // Output some statistics. Well done! :-)
    echo 'There are '.count($items)." items.\n";
    echo "The first item has media id: {$firstItem_mediaId}.\n";
    echo "The first item was uploaded by: {$firstItem_username}.\n";
    echo "The highest quality image URL is: {$firstItem_imageUrl}.\n";
} catch (\Exception $e) {
echo 'Something went wrong: '.$e->getMessage()."\n";
}
?>

运行此代码后,打印的唯一内容是 hey1 和 hey2。根据我自己的研究,我得出的结论是 autoload.php 是作曲家运行的必要文件之一,但它似乎也是阻止 php 运行的问题。此代码来自https://github.com/mgp25/Instagram-API。佩斯帮忙!

【问题讨论】:

  • 这个文件存在吗?你是通过composer安装的吗?您是否尝试过开启错误报告和显示?
  • 刚要问@kerbholz 所做的同样的事情:您实际上是在任何时候安装了 composer 还是只是将 repo 下载为 zip 文件?
  • 我有作曲家,如何开启错误报告
  • 我会安装并回复你们

标签: php server instagram-api


【解决方案1】:

1) 如果您没有 Composer,请安装它。例如:

sudo apt-get install composer -y

2) 运行:

composer require mgp25/instagram-php

3) 类型:

cd vendor
ls

您看到列出的第一个文件应该是 autoload.php。

【讨论】:

    猜你喜欢
    • 2019-10-08
    • 2018-11-10
    • 2015-09-18
    • 2013-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-14
    相关资源
    最近更新 更多