我在FacebookCurl.php的第66行有这个错误....“数组到字符串转换”,我正在尝试更新这个:custom_image from page / 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
}
FacebookCurl.php第66行中的“数组到字符串转换”错误说明......
<?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);
}
你能帮我吗?
答案 0 :(得分:0)
在$custom_image
中看起来只需要图像的path
,但您要为其分配整个$_FILES[]
复合数组。
请尝试使用此$custom_image=$_FILES['custom_image'];
替换代码中的这一行$custom_image=$_FILES['custom_image']['tmp_name'];
并查看其是否有效