PHP致命错误:在第66行的/home/mona/computer_vision/Instagram-API/src/Instagram.php中找不到类'InstagramAPI \ HttpInterface'

时间:2017-03-06 22:43:18

标签: php http instagram instagram-api

我收到此错误:

mona@pascal:~/computer_vision/Instagram-API/examples$ php PaginationExample.php 
PHP Warning:  include(/home/mona/computer_vision/Instagram-API/examples/../vendor/autoload.php): failed to open stream: No such file or directory in /home/mona/computer_vision/Instagram-API/examples/PaginationExample.php on line 3
PHP Warning:  include(): Failed opening '/home/mona/computer_vision/Instagram-API/examples/../vendor/autoload.php' for inclusion (include_path='.:/usr/share/php') in /home/mona/computer_vision/Instagram-API/examples/PaginationExample.php on line 3
PHP Fatal error:  Class 'InstagramAPI\HttpInterface' not found in /home/mona/computer_vision/Instagram-API/src/Instagram.php on line 66

最新版本Instagram.php中的第66行是:

$this->http = new HttpInterface($this);

mona@pascal:~/computer_vision/Instagram-API/examples$ vi PaginationExample.php 
mona@pascal:~/computer_vision/Instagram-API/examples$ ls ../src/
ChallengeSMS.php  Checkpoint.php  Constants.php  data  http  InstagramException.php  Instagram.php  InstagramRegistration.php  SignatureUtils.php  Utils

我还有:

mona@pascal:~/computer_vision/Instagram-API$ tree
.
├── composer.json
├── CONTRIBUTING.md
├── Dockerfile
├── examples
│   ├── accessingValues.php
│   ├── assets
│   │   └── instagram.png
│   ├── challengeSMS.php
│   ├── checkpoint.php
│   ├── exception.php
│   ├── PaginationExample.php
│   ├── Readme.md
│   ├── registrationTool.php
│   ├── uploadAlbum.php
│   ├── uploadPhoto.php
│   ├── uploadVideo.php
│   └── usingMemcachedSettingsAdapter.php
├── LICENSE
├── README.md
└── src
    ├── ChallengeSMS.php
    ├── Checkpoint.php
    ├── Constants.php
    ├── data
    ├── http
    │   ├── devices.csv
    │   ├── HttpInterface.php
    │   ├── Response
    │   │   ├── AccountCreationResponse.php
    │   │   ├── ActivityNewsResponse.php
    │   │   ├── AddressBookResponse.php
    │   │   ├── autoCompleteUserListResponse.php
    │   │   ├── ChallengeResponse.php
    │   │   ├── ChangePasswordResponse.php
    │   │   ├── CheckEmailResponse.php
    │   │   ├── CheckUsernameResponse.php
    │   │   ├── CommentLikeUnlikeResponse.php
    │   │   ├── CommentResponse.php
    │   │   ├── ConfigureResponse.php
    │   │   ├── ConfigureVideoResponse.php
    │   │   ├── DeleteCommentResponse.php
    │   │   ├── DirectShareInboxResponse.php
    │   │   ├── DiscoverChannelsResponse.php
    │   │   ├── EditMediaResponse.php
    │   │   ├── ExploreResponse.php
    │   │   ├── ExposeResponse.php
    │   │   ├── FBLocationResponse.php
    │   │   ├── FBSearchResponse.php
    │   │   ├── FollowerAndFollowingResponse.php
    │   │   ├── FollowingRecentActivityResponse.php
    │   │   ├── FriendshipResponse.php
    │   │   ├── FriendshipsShowManyResponse.php
    │   │   ├── GeoMediaResponse.php
    │   │   ├── InsightsResponse.php
    │   │   ├── LikeFeedResponse.php
    │   │   ├── LocationFeedResponse.php
    │   │   ├── LocationResponse.php
    │   │   ├── LoginResponse.php
    │   │   ├── LogoutResponse.php
    │   │   ├── MediaCommentsResponse.php
    │   │   ├── MediaDeleteResponse.php
    │   │   ├── MediaInfoResponse.php
    │   │   ├── MediaInsightsResponse.php
    │   │   ├── MediaLikersResponse.php
    │   │   ├── MegaphoneLogResponse.php
    │   │   ├── Objects
    │   │   │   ├── Args.php
    │   │   │   ├── Caption.php
    │   │   │   ├── CarouselMedia.php
    │   │   │   ├── Comment.php
    │   │   │   ├── Counts.php
    │   │   │   ├── Experiment.php
    │   │   │   ├── Explore.php
    │   │   │   ├── FeedAysf.php
    │   │   │   ├── FriendshipStatus.php
    │   │   │   ├── GeoMedia.php
    │   │   │   ├── Hashtag.php
    │   │   │   ├── Hashtags.php
    │   │   │   ├── HdProfilePicUrlInfo.php
    │   │   │   ├── Image_Versions2.php
    │   │   │   ├── Inbox.php
    │   │   │   ├── In.php
    │   │   │   ├── Insights.php
    │   │   │   ├── Item.php
    │   │   │   ├── Link.php
    │   │   │   ├── LocationItem.php
    │   │   │   ├── Location.php
    │   │   │   ├── MediaInsights.php
    │   │   │   ├── Media.php
    │   │   │   ├── _Message.php
    │   │   │   ├── Param.php
    │   │   │   ├── Place.php
    │   │   │   ├── Position.php
    │   │   │   ├── Reel.php
    │   │   │   ├── RowItem.php
    │   │   │   ├── SavedFeedItem.php
    │   │   │   ├── Story.php
    │   │   │   ├── Suggestion.php
    │   │   │   ├── Tag.php
    │   │   │   ├── ThreadItem.php
    │   │   │   ├── Thread.php
    │   │   │   ├── Tray.php
    │   │   │   ├── User.php
    │   │   │   ├── Users.php
    │   │   │   ├── Usertag.php
    │   │   │   └── VideoVersions.php
    │   │   ├── PendingInboxResponse.php
    │   │   ├── PopularFeedResponse.php
    │   │   ├── ProfileResponse.php
    │   │   ├── RankedRecipientsResponse.php
    │   │   ├── RecentRecipientsResponse.php
    │   │   ├── ReelsMediaResponse.php
    │   │   ├── ReelsTrayFeedResponse.php
    │   │   ├── Response.php
    │   │   ├── SaveAndUnsaveMedia.php
    │   │   ├── SavedFeedResponse.php
    │   │   ├── SearchTagResponse.php
    │   │   ├── SearchUserResponse.php
    │   │   ├── SuggestedUsersResponse.php
    │   │   ├── SyncResponse.php
    │   │   ├── TagFeedResponse.php
    │   │   ├── TagInfoResponse.php
    │   │   ├── TagRelatedResponse.php
    │   │   ├── TimelineFeedResponse.php
    │   │   ├── UploadJobVideoResponse.php
    │   │   ├── UploadPhotoResponse.php
    │   │   ├── UploadVideoResponse.php
    │   │   ├── UserFeedResponse.php
    │   │   ├── UsernameInfoResponse.php
    │   │   ├── UsernameSuggestionsResponse.php
    │   │   ├── UserStoryFeedResponse.php
    │   │   ├── UsertagsResponse.php
    │   │   └── V2InboxResponse.php
    │   └── UserAgent.php
    ├── InstagramException.php
    ├── Instagram.php
    ├── InstagramRegistration.php
    ├── SignatureUtils.php
    └── Utils
        ├── AdaptImage.php
        ├── AutoResponseFunctionSetter.php
        ├── Debug.php
        ├── SettingsAdapter
        │   ├── Memcached.php
        │   └── SettingsInterface.php
        ├── SettingsAdapter.php
        ├── SettingsFile.php
        ├── SettingsMysql.php
        └── Utils.php

9 directories, 140 files

PaginationExample.php的代码如下:

<?php

include __DIR__.'/../vendor/autoload.php';
require '../src/Instagram.php';

/////// CONFIG ///////
$username = 'mona_of_green_gables';
$password = '';
$debug = false;
$truncatedDebug = false;
//////////////////////

// THIS IS AN EXAMPLE OF HOW TO USE NEXT_MAX_ID TO PAGINATE
// IN THIS EXAMPLE, WE ARE RETRIEVING SELF FOLLOWERS
// BUT THE PROCESS IS SIMILAR IN OTHER REQUESTS

$i = new \InstagramAPI\Instagram($debug);

$i->setUser($username, $password);

//$buzzfeed_id = $i->getUsernameId('buzzfeed');
//$mona_id = $i->getUsernameId('mona_of_green_gables');
try {
    $i->login();
} catch (Exception $e) {
    echo 'something went wrong '.$e->getMessage()."\n";
    exit(0);
}
try {

    $helper = null;
    $followers = [];

    do {
        if (is_null($helper)) {
            $helper = $i->getUserFollowers(220004286);
        } else {
            $helper = $i->getUserFollowers(220004286, $helper->getNextMaxId());
        }

        $followers = array_merge($followers, $helper->getUsers());
    } while (!is_null($helper->getNextMaxId()));

    echo "My followers: \n";
    foreach ($followers as $follower) {
       echo '- '.$follower->getUsername()."\n";
    }

    sleep(6);

    $comment_helper = null;
    $comments = [];

    do {
        if (is_null($comment_helper)) {
            $comment_helper = $i->getMediaComments(1432492921000850400);
        } else {
            $comment_helper = $i->getMediaComments(1432492921000850400, $comment_helper->getNextMaxId());
        }
        $comments = array_merge($comments, $comment_helper->getComments());
    } while (!is_null($comment_helper->getNextMaxId()));

    foreach ($comments as $comment){
        echo '- '.$comment->text."\n";
    }

    //echo "buzzfeed user id is $buzzfeed_id \n";
    //echo "monamona user id is $mona_id \n";
/*   
 $likers = $i->getMediaLikers(1462813261661883124);
    #die(var_dump($likers)) ;
    foreach ($likers->users as $user) { 
        //echo 'PK is '.$user->pk ."\n"; 
    }
  */
   /* 
    $comments = $i->getMediaComments(1460989950795454007);
    #die(var_dump($comments));     
    foreach ($comments->comments as $comment) {
        echo 'comment is '.$comment->text ."\n";
    } 
*/
    $users_tag = $i->getUserTags(53112486);  
    $i->getMediaInfos(53112486);
    //print_r(get_object_vars($users_tag));    
//die(var_dump($users_tag));
    //json_decode($i, true); 
} catch (Exception $e) {
    echo $e->getMessage();
}

我正在使用此API: https://github.com/mgp25/Instagram-API

正在搜索httpinterface我有以下内容:

mona@pascal:~/computer_vision/Instagram-API$ grep -irn "httpinterface" *
src/http/HttpInterface.php:9:class HttpInterface
src/http/HttpInterface.php:91:     * Resets certain HttpInterface settings via the current SettingsAdapter.
src/http/HttpInterface.php:183:     * Controls the SSL verification behavior of the HttpInterface.
src/http/HttpInterface.php:198:     * Gets the current SSL verification behavior of the HttpInterface.
src/Utils/SettingsFile.php:7:    public $cookiesPath; // public becouse used by HttpInterface
src/Instagram.php:29:     * @var HttpInterface
src/Instagram.php:66:        $this->http = new HttpInterface($this);
src/Instagram.php:103:        // Configures HttpInterface for current user AND updates isLoggedIn
src/Instagram.php:1967:     * Controls the SSL verification behavior of the HttpInterface.
src/Instagram.php:1982:     * Gets the current SSL verification behavior of the HttpInterface.
src/Instagram.php:2049: * Bridge between HttpInterface object & mapper & response.

1 个答案:

答案 0 :(得分:0)

以下命令修复了错误:

mkdir -p test && cd test && composer require mgp25/instagram-php
cp ../examples/PaginationExample.php .