tumblr / tumblr.php

Tumblr API v2 PHP Client
Apache License 2.0
407 stars 115 forks source link

Fatal error: Class 'Tumblr\API\Client' not found #41

Closed patelmegha887 closed 9 years ago

patelmegha887 commented 10 years ago

i got this error when i run my file my code is here <?php session_start(); ini_set("display_errors", 1);

//include 'lib/Tumblr/API/Keys.php'; // I have created a new file Keys.php //It carries consumer-key, secret, token, token-secret $consumerKey = '-------------------------------'; $consumerSecret = '------------------------------------'; $token = '-----------------------------------------'; $tokenSecret = '-------------------------------------'; include 'vendor/autoloadManager.php';

use Tumblr\API;

$client = new Tumblr\API\Client($consumerKey, $consumerSecret);

//$token = $_SESSION['oauth_token']; //$tokenSecret = $_SESSION['oauth_token_secret'];

$client->setToken($token, $tokenSecret);

print '

';

// Retrieve User Info $user_info = $client->getUserInfo(); print_r($user_info);

foreach ($client->getUserInfo()->user->blogs as $blog) { print_r($blog); echo $blog->name . "\n"; } ?>

khurshid-alam commented 10 years ago

Did you install tumblr library through composer? If you did , then it shoud be include('vendor/autoload.php)'.

If you didn't , then load the class by directly pointing to the 'tumblr.php'.

patelmegha887 commented 10 years ago

i directly put tumblr library in server folder didnt install through composer.. is it fine or not?

codingjester commented 10 years ago

I think I need you to use a gist or something similar of what you've built. I think @khurshid-alam it's telling you that you'll need to require the tumblr.php file in the top of your script to load the actual client library.

patelmegha887 commented 10 years ago

sorry for late reply i tried lot i install composer but autoload file cant be generated...is there another way?

patelmegha887 commented 10 years ago

does we need to change composer,json file.... bcause when i install it it generate 4-5 autoload file i try to use every file still it dosent work

khurshid-alam commented 10 years ago

@patelmegha887

sorry for late reply i tried lot i install composer but autoload file cant be generated...is there another way?

Is it showing any error? Does it create vendor/tumblr folder?

Which distro/OS & php version are you using? You should update composer first before doing anything. Try running php composer.phar update first. For more command-line usage look here: https://getcomposer.org/doc/01-basic-usage.md

The commands I have given (above & below) works fine on Ubuntu(>=12.04) with php 5.5

Your composer.json should look like this

{
    "require": {
        "tumblr/tumblr": "0.1.1"
    }
}

First manually create the file, then run php composer.phar install. It will generate a single autoload file inside vendor.