У меня есть эта ошибка.... "array to string conversion" в строке 66 в FacebookCurl.php, я пытаюсь обновить это: custom_image со страницы /tabs/app_id...
Я получаю значение custom_image из файла входного типа и использую multipart/form-data....
Это мой код в php...
session_start();
require '/../../vendor/autoload.php';
require '/../config/configfb.php';
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\GraphUser;
use Facebook\GraphObject;
use Facebook\FacebookRequestException;
//app_id and secret
FacebookSession::setDefaultApplication($config['appId'], $config['secret']);
$helper = new FacebookRedirectLoginHelper('xxxxxxxxxx');
try {
$session = $helper->getSessionFromRedirect();
if($session):
$_SESSION['facebook']=$session->getToken();
header('Location: xxxx');
endif;
if (isset($_SESSION['facebook'])):
$session = new FacebookSession($_SESSION['facebook']);
if (isset($_POST['custom_name']))
{
//get value of input type text custom_name
$custom_name=$_POST['custom_name'];
//get value of input type file custom_image
$custom_image=$_FILES['custom_image'];
//get the access token
$request = new FacebookRequest($session, 'GET', '/me/accounts');
$response = $request->execute();
$getAcounts = $response->getGraphObject()->asArray();
foreach ($getAcounts['data'] as $keyAcc) {
$keyAcc ->id;
if($keyAcc->id == $page){
$_SESSION['access_token']=$keyAcc->access_token;
}
}
$access_token=$_SESSION['access_token'];
$session = new FacebookSession($access_token);
//Update custom_name and custom_image
$request = new FacebookRequest($session, 'POST', '/'.$tab,
array (
'custom_name' => $custom_name
'custom_image' => $custom_image
)
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
$request = new FacebookRequest($session, 'GET', '/'.$tab);
$response = $request->execute();
$getInf = $response->getGraphObject()->asArray();
$_SESSION['getInf'] = $getInf;
}
endif;
}
catch(FacebookRequestException $ex) {
// When Facebook returns an error
}
catch(\Exception $ex) {
// When validation fails or other local issues
}
if ($session) {
// Logged in
}
Ошибка "array to string conversion" в строке 66 в FacebookCurl.php говорит об этом...
<?php
/**
* Set an array of options to a curl resource
*
* @param array $options
*/
public function setopt_array(array $options)
{
curl_setopt_array($this->curl, $options);
}
Не могли бы вы мне помочь?
Похоже, что в $custom_image
только path
к изображению, но вы назначаете ему целый $_FILES[]
. Попробуйте заменить эту строку $custom_image=$_FILES['custom_image'];
в вашем коде с этим, $custom_image=$_FILES['custom_image']['tmp_name'];
и посмотреть, работает ли он