laravel 5.1显示没有找到“Facebook \ Facebook”类

时间:2016-02-06 09:49:39

标签: facebook api facebook-graph-api laravel-4 laravel-5.1

fb调用api上传照片

  <?php
  $fb = new Facebook\Facebook([
 'app_id' => '',
 'app_secret' => '',
 'default_graph_version' => 'v2.5',
  ]);

$data = [
 'message' => 'My awesome photo upload example.',
 'source' => $fb->fileToUpload('C:/xampp/htdocs/laravel5-learning/public/image/share/'.$name),
 ];

 try {
 // Returns a `Facebook\FacebookResponse` object
 $response = $fb->post('/me/photos', $data, '{access-token}');
 } catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
 echo 'Facebook SDK returned an error: ' . $e->getMessage();
 exit;
}


$graphNode = $response->getGraphNode();

echo 'Photo ID: ' . $graphNode['id'];

  ?>

我在控制器文件中使用的类

我认为我需要包含更多可以正常运作的课程。请帮我告诉我需要打电话

    use Illuminate\Http\Request;
    //use Session;
   //use Request;
   use DB;
   use DateTime;
    //use App\Locations;
    use App\Http\Requests;
    use App\Http\Controllers\Controller;

    use Facebook\Facebook as Facebook;
    use Facebook\FileUpload\FacebookFile;
    use Facebook\FacebookRequest;
    use Facebook\GraphObject;
    use Facebook\FacebookRequestException;

显示此错误,即'找不到'Facebook \ Facebook'

1 个答案:

答案 0 :(得分:0)

只需使用以下命令在作曲家中添加社交名称即可。

composer require laravel/socialite

如果您想了解更多内容,请阅读this

快乐编码:)。