在FacebookCurl.php中发生错误“数组到字符串转换”

uqui 发布于 2019-06-12 facebook 最后更新 2019-06-12 21:16 2 浏览

我有这个错误....在FacebookCurl.php行66中的“字符串转换数组”,我试图更新此:custom_image从页面/选项卡/ 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);
  }
你能帮我吗?
已邀请:

taut

赞同来自:

看起来在$custom_image中只需要path到图像,但是您要为其分配整个$_FILES[]复合数组。 尝试使用此$custom_image=$_FILES['custom_image']['tmp_name'];替换代码中的此行$custom_image=$_FILES['custom_image'];,看看它是否有效