ashwinks / PHP-LinkedIn-SDK

A PHP wrapper for the LinkedIn API
94 stars 75 forks source link

Fatal error: Class 'LinkedIn' not found #19

Closed sumitkanoje closed 9 years ago

sumitkanoje commented 9 years ago

Hi, I am using code like this and getting class not found error. I already checked if the file is included correctly or not using get_included_files(), still this is happening. Where I'm going wrong??

<?php

include 'lib/LinkedIn/LinkedIn.php';

print_r(get_included_files()); 
$li = new LinkedIn(
  array(
    'api_key' => 'myapikey', 
    'api_secret' => 'myapisecret', 
    'callback_url' => 'https://mydomain.com/redirecthere'
  )
);

?>
sumitkanoje commented 9 years ago

Just to inform you: I just removed namespace from file LinkedIn.php (Line3), and it worked. Issue might be because I'm not using composer. PS: Thanks for not replying

ghost commented 9 years ago

I guess you should do:

require_once 'LinkedIn/LinkedIn.php'; use LinkedIn\LinkedIn;

mikaelz commented 9 years ago

It is namespaced so as @ghost wrote you need to have use line with the namespace or can use

$li = new LinkedIn\LinkedIn(
  array(
    'api_key' => 'myapikey', 
    'api_secret' => 'myapisecret', 
    'callback_url' => 'https://mydomain.com/redirecthere'
  )
);