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'
答案 0 :(得分:0)