上传照片/视频Facebook的异步使用PHP SDK 4 [英] Upload image/video to facebook asynchronously using php sdk 4

查看:318
本文介绍了上传照片/视频Facebook的异步使用PHP SDK 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想上传视频/图像给Facebook albumb使用PHP SDK 4 asynchronously.I一派,发现PHP的异步调用使用传送的fsockopen 。然而,它不工作Facebook的请求。我有两个文件,​​一个检查登录并获得令牌。然后,第二个文件是要求将文件上传到Facebook。下面是code为第一个文件:

  //启动会话
在session_start();Yii的进口::('application.vendor *。');
require_once(的Facebook-4 / autoload.php');使用Facebook \\ HttpClients \\ FacebookHttpable;
使用Facebook \\ HttpClients \\ FacebookCurl;
使用Facebook \\ HttpClients \\ FacebookCurlHttpClient;使用Facebook \\实体\\的accessToken;
使用Facebook \\实体\\ SignedRequest;使用Facebook \\ FacebookSession;
使用Facebook \\ FacebookRedirectLoginHelper;
使用Facebook \\ FacebookRequest;
使用Facebook \\ FacebookResponse;
使用Facebook \\ FacebookSDKException;
使用Facebook \\ FacebookRequestException;
使用Facebook \\ FacebookOtherException;
使用Facebook \\ FacebookAuthorizationException;
使用Facebook \\ GraphObject;
使用Facebook \\ GraphSessionInfo;
//初始化应用程序与应用程序ID和秘密
FacebookSession :: setDefaultApplication('XXXXX','YYYY');//登录助手与REDIRECT_URI
$帮手=新FacebookRedirectLoginHelper('http://website.com/user/login/page/view/fb-share-php1');//查看一个现有的会话存在
如果(使用isset($ _SESSION)及和放大器;使用isset($ _SESSION ['fb_token'])){
    //创建保存的access_token新的会话
    $会话=新FacebookSession($ _SESSION ['fb_token']);
    //验证的access_token,以确保它仍然是有效的
    尝试{
        如果($会话级>!验证()){
            $会话= NULL;
        }
    }赶上(例外$ E){
        //捕获任何异常
        $会话= NULL;
    }
}如果(!使用isset($会话)|| $会话=== NULL){
    //会话不存在
    尝试{
        $会议= $ helper-> getSessionFromRedirect();
    }赶上(FacebookRequestException $前){
    //当Facebook返回一个错误
    //生产code处理这更好
    的print_r($前);
    }赶上(例外$前){
        //如果验证失败或其他地方的问题
        //生产code处理这更好
        的print_r($前);
    }
}//看看我们是否有一个会话
如果(使用isset($会话)){
    //保存会话
    $ _SESSION ['FB'] = $会议;
    $ _SESSION ['fb_token'] = $会话级>为gettoken();
    //创建一个会话中使用保存令牌或我们在登录时产生的新
    // $会话=新FacebookSession($会话级>为gettoken());
    //用户数据的图形API请求
    // $ =请求新FacebookRequest($会议上,GET,/我);
    // $响应= $请求 - >执行();
    backgroundPost('http://website.com/user/login/page/view/fb-share-php');
    //获取响应
    // $ graphObject = $响应 - > getGraphObject() - GT; asArray();
    //打印文件数据
    //回声'< pre>' 。的print_r($ graphObject,1)。 '< / pre>';
    使用会话和REDIRECT_URI //打印注销URL(logout.php页面应该销毁会话)
    呼应'< A HREF ='$ helper-方式> getLogoutUrl($会议上,http://website.com/user/login/page/view/fb-share-php1')'。>注销&LT ; / A>';
}其他{
    //显示登录URL
    呼应'< A HREF ='$ helper-方式> getLoginUrl(阵列('邮件','user_friends'))。'>登录和LT; / A>';
}
功能backgroundPost($网址){
    $部分= parse_url($网址);
    //的print_r($部分);退出;    $计划生育=的fsockopen($部件['主机'],
            使用isset($部件['口'])$部件['端口']:80,
            $的errno,$ errstr,30);    如果(!$ FP){
        回声测试;
        返回false;
    }其他{
        从$ =POST$零件[路径]HTTP / 1.1 \\ r \\ n。
        。$ OUT =主持人:$零件['主机']为\\ r \\ n。
        $ OUT =内容类型:应用程序/ x-WWW的形式urlen codeD \\ r \\ n;
        从$ =内容长度:。 0\\ r \\ n。
        $ OUT =。曲奇:PHPSESSID =。 $ _COOKIE ['PHPSESSID。 \\ r \\ n;
        从$ =连接:关闭\\ r \\ n \\ r \\ n。
        如果(使用isset($部件['查询']))$ OUT = $部件['查询']。
        //的print_r($出);退出;
        FWRITE($ FP,$出);
        FCLOSE($ FP);
        返回true;
    }
}

和第二个文件是:

  //启动会话
在session_start();
Yii的进口::('application.vendor *。');
require_once(的Facebook-4 / autoload.php');使用Facebook \\ HttpClients \\ FacebookHttpable;
使用Facebook \\ HttpClients \\ FacebookCurl;
使用Facebook \\ HttpClients \\ FacebookCurlHttpClient;使用Facebook \\实体\\的accessToken;
使用Facebook \\实体\\ SignedRequest;使用Facebook \\ FacebookSession;
使用Facebook \\ FacebookRedirectLoginHelper;
使用Facebook \\ FacebookRequest;
使用Facebook \\ FacebookResponse;
使用Facebook \\ FacebookSDKException;
使用Facebook \\ FacebookRequestException;
使用Facebook \\ FacebookOtherException;
使用Facebook \\ FacebookAuthorizationException;
使用Facebook \\ GraphObject;
使用Facebook \\ GraphSessionInfo;$会议= $ _SESSION ['FB'];
的file_put_contents('file.txt的',序列化($ session中));
尝试{    //上传到用户的个人资料。照片将在
    //在配置文件中的第一张专辑。您也可以上传到
    //特定相册使用/ ALBUM_ID作为路径
    $响应=(新FacebookRequest(
            $ session中,POST,/ ME /照片,阵列(
                    '源'=> @ /无功/网络/网站根/图像/ add_more.png',
                    '消息'= GT; 用户提供信息
            )
    )) - >执行() - GT; getGraphObject();
    的file_put_contents('files.txt',序列化($ session中));
    //如果你不使用PHP 5.5或更高版本,更改文件引用:
    //'源'=> @ /路径/要/ file.name    //回声发布id为:。 $响应 - >的getProperty('身份证');}赶上(FacebookRequestException $ E){    回声异常发生,code:。 $ E-GT&;获得code();
    回声与消息:。 $ E-GT&;的getMessage();}


解决方案

最后,我想通了,以实现它的方式。现在,我使用的JavaScript的Facebook SDK使用PHP SDK。以下是过程:

1)获取从JavaScript SDK(第一档)访问令牌并将它传递给背景图像/视频的URL一起。 code可能会被修改,如果图像/视频是通过源代码上传。

2)含有用于执行后端处理(这是在第三档的功能PHP文件(第二档))接收发布的数据,并并调用第三个文件(以URL的形式)和数据传递给它,以及

3)文件(S)通过PHP SDK上传到Facebook的4(第三档)

下面是code为包含JavaScript SDK code第一个文件:

 <脚本>      (函数(D,S,id)的{
         变种JS,FJS = d.getElementsByTagName(多个)[0];
         如果(d.getElementById(ID)){回报;}
         JS = d.createElement(S); js.id = ID;
         js.src =//connect.facebook.net/en_US/sdk.js;
         fjs.parentNode.insertBefore(JS,FJS);
       }(文件,脚本,Facebook的jssdk'));
        window.fbAsyncInit =功能(){
        FB.init({
          APPID:'您的应用程序ID',
          XFBML:真实,
          版本:'2.0'
        });
        FB.login(功能(响应){
            的console.log(响应);
            如果(response.status ==='连接'){
                VAR数据=新的Array();                警报('登录到您的应用程序和Facebook。');
                //类型:0照片并类型:视频1。动态地创建真正的字应用程序的数据阵列
                数据[0] = {网址:'HTTP://url-of-video-file.mov',privacy:自我,留言:视频标题中输入:1};
                数据[1] = {URL:HTTP://url-to-image-file.png',privacy:自我,留言:照片的标题中输入:0};
                $阿贾克斯({
                    网址:HTTP:// URL-的秒的文件/载有code-用于/后端进程,
                    数据:{数据:数据的accessToken:response.authResponse.accessToken},
                    输入:POST,
                    成功:函数(){
                        警报(照片上传);
                    }                });
        },{范围:电子邮件});
    }< / SCRIPT>

现在$第二个文件的C $ç接收数据并执行后端流程:

 < PHP//在session_start();
ignore_user_abort(真正的);
或者set_time_limit(0);功能backgroundPost($网址){
    $部分= parse_url($网址);
    //的print_r($部分);退出;    $计划生育=的fsockopen($部件['主机'],
            使用isset($部件['口'])$部件['端口']:80,
            $的errno,$ errstr,30);    如果(!$ FP){
        回声测试;
        返回false;
    }其他{
        $瓦尔= $ _ POST;        $内容= http_build_query($瓦尔);
        //file_put_contents('url.txt',$content);exit;
        从$ =POST$零件[路径]HTTP / 1.1 \\ r \\ n。
        。$ OUT =主持人:$零件['主机']为\\ r \\ n。
        $ OUT =内容类型:应用程序/ x-WWW的形式urlen codeD \\ r \\ n;
        从$ =内容长度:。 strlen的($内容)为\\ r \\ n。
        // $ OUT =。曲奇:PHPSESSID =。 $ _COOKIE ['PHPSESSID。 \\ r \\ n;
        从$ =连接:关闭\\ r \\ n \\ r \\ n。
        如果(使用isset($部件['查询']))$ OUT = $部件['查询']。
        //的print_r($出);退出;
        FWRITE($ FP,$出);
        FWRITE($ FP,$内容);
        FCLOSE($ FP);
        返回true;
    }
}
backgroundPost(的http://链接到第三个文件/载有code换的Facebook上传');

现在$第三个文件的C $ C,它实际上将上传的文件。请注意,视频文件需要它可以被上传之前被下载。

 < PHP//启动会话
//在session_start();
(1)使用error_reporting;
ignore_user_abort(真正的);
或者set_time_limit(0);
@ini_set('的display_errors',1);
//包括通过自动加载的Facebook库
require_once(的Facebook-4 / autoload.php');使用Facebook \\ HttpClients \\ FacebookHttpable;
使用Facebook \\ HttpClients \\ FacebookCurl;
使用Facebook \\ HttpClients \\ FacebookCurlHttpClient;使用Facebook \\实体\\的accessToken;
使用Facebook \\实体\\ SignedRequest;使用Facebook \\ FacebookSession;
使用Facebook \\ FacebookRedirectLoginHelper;
使用Facebook \\ FacebookRequest;
使用Facebook \\ FacebookResponse;
使用Facebook \\ FacebookSDKException;
使用Facebook \\ FacebookRequestException;
使用Facebook \\ FacebookOtherException;
使用Facebook \\ FacebookAuthorizationException;
使用Facebook \\ GraphObject;
使用Facebook \\ GraphSessionInfo;//初始化应用程序与应用程序ID和秘密
FacebookSession :: setDefaultApplication('APP_ID','SECRET_KEY');
$会话=新FacebookSession($ _ POST ['的accessToken']);的foreach($ _ POST ['数据']为$关键=> $数据){
    如果($数据['类型'] == 1){
        $ EXT = SUBSTR($数据['URL'],strrpos($数据['URL'])'。');
        $文件='/path/to/temp/location/for/saving/video/'.time().$ext;
        如果(的file_put_contents($文件的file_get_contents($数据['URL']))){
            尝试{                //上传到用户的个人资料。照片将在
                //在配置文件中的第一张专辑。您也可以上传到
                //特定相册使用/ ALBUM_ID作为路径
                $响应=(新FacebookRequest(
                        $ session中,POST,/ ME /视频,阵列(
                                '源'=> '@'。$文件,
                                '标题'=> $数据['消息'],
                                '隐私'=> json_en code(阵列('值'=> $数据['隐私']))
                                '发表'=>真正
                        )
                )) - >执行() - GT; getGraphObject() - GT; asArray();                //如果你不使用PHP 5.5或更高版本,更改文件引用:
                //'源'=> @ /路径/要/ file.name                //回声发布id为:。 $响应 - >的getProperty('身份证');            }赶上(FacebookRequestException $ E){                回声异常发生,code:。 $ E-GT&;获得code();
                回声与消息:。 $ E-GT&;的getMessage();
            }
        }
    }其他{
        尝试{            //上传到用户的个人资料。照片将在
            //在配置文件中的第一张专辑。您也可以上传到
            //特定相册使用/ ALBUM_ID作为路径
            $响应=(新FacebookRequest(
                    $ session中,POST,/ ME /照片,阵列(
                            'URL'=> $数据['URL'],
                            '消息'= GT; $数据['消息'],
                            '隐私'=> json_en code(阵列('值'=> $数据['隐私']))
                            '发表'=>真正
                    )
            )) - >执行() - GT; getGraphObject() - GT; asArray();            //如果你不使用PHP 5.5或更高版本,更改文件引用:
            //'源'=> @ /路径/要/ file.name            //回声发布id为:。 $响应 - >的getProperty('身份证');        }赶上(FacebookRequestException $ E){            回声异常发生,code:。 $ E-GT&;获得code();
            回声与消息:。 $ E-GT&;的getMessage();
        }
    }
}
    ?>

I am trying to upload video/image to facebook albumb using php sdk 4 asynchronously.I googled and found that php asynchronous call be sent using fsockopen. However, it is not working for facebook request. I have two files, one for checking login and getting token. Then second file is called for uploading the file to facebook. Below is the code for first file:

// start session
session_start();

Yii::import('application.vendor.*');
require_once('facebook-4/autoload.php');

use Facebook\HttpClients\FacebookHttpable;
use Facebook\HttpClients\FacebookCurl;
use Facebook\HttpClients\FacebookCurlHttpClient;

use Facebook\Entities\AccessToken;
use Facebook\Entities\SignedRequest;

use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookOtherException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\GraphSessionInfo;


// init app with app id and secret
FacebookSession::setDefaultApplication('xxxxx', 'yyyy');

// login helper with redirect_uri
$helper = new FacebookRedirectLoginHelper( 'http://website.com/user/login/page/view/fb-share-php1' );

// see if a existing session exists
if ( isset( $_SESSION ) && isset( $_SESSION['fb_token'] ) ) {
    // create new session from saved access_token
    $session = new FacebookSession( $_SESSION['fb_token'] );
    // validate the access_token to make sure it's still valid
    try {
        if ( !$session->validate() ) {
            $session = null;
        }
    }catch ( Exception $e ) {
        // catch any exceptions
        $session = null;
    }
}

if ( !isset( $session ) || $session === null ) {
    // no session exists
    try {
        $session = $helper->getSessionFromRedirect();
    } catch( FacebookRequestException $ex ) {
    // When Facebook returns an error
    // handle this better in production code
    print_r( $ex );
    } catch( Exception $ex ) {
        // When validation fails or other local issues
        // handle this better in production code
        print_r( $ex );
    }
}

// see if we have a session
if ( isset( $session ) ) {
    // save the session
    $_SESSION['fb'] = $session;
    $_SESSION['fb_token'] = $session->getToken();
    // create a session using saved token or the new one we generated at login
    //$session = new FacebookSession( $session->getToken() );
    // graph api request for user data
    //$request = new FacebookRequest( $session, 'GET', '/me' );
    //$response = $request->execute();
    backgroundPost('http://website.com/user/login/page/view/fb-share-php');
    // get response
    //$graphObject = $response->getGraphObject()->asArray();
    // print profile data
    //echo '<pre>' . print_r( $graphObject, 1 ) . '</pre>';
    // print logout url using session and redirect_uri (logout.php page should destroy the session)
    echo '<a href="' . $helper->getLogoutUrl( $session, 'http://website.com/user/login/page/view/fb-share-php1' ) . '">Logout</a>';
}else {
    // show login url
    echo '<a href="' . $helper->getLoginUrl( array( 'email', 'user_friends' ) ) . '">Login</a>';
}
function backgroundPost($url){
    $parts=parse_url($url);
    //print_r($parts);exit;

    $fp = fsockopen($parts['host'],
            isset($parts['port'])?$parts['port']:80,
            $errno, $errstr, 30);

    if (!$fp) {
        echo "test";
        return false;
    } else {
        $out = "POST ".$parts['path']." HTTP/1.1\r\n";
        $out.= "Host: ".$parts['host']."\r\n";
        $out.= "Content-Type: application/x-www-form-urlencoded\r\n";
        $out.= "Content-Length: ". 0 ."\r\n";
        $out .= "Cookie: PHPSESSID=" . $_COOKIE['PHPSESSID'] . "\r\n";
        $out .= "Connection: Close\r\n\r\n";
        if (isset($parts['query'])) $out.= $parts['query'];
        // print_r($out);exit;
        fwrite($fp, $out);
        fclose($fp);
        return true;
    }
}

And second file is:

 // start session
session_start();
Yii::import('application.vendor.*');
require_once('facebook-4/autoload.php');

use Facebook\HttpClients\FacebookHttpable;
use Facebook\HttpClients\FacebookCurl;
use Facebook\HttpClients\FacebookCurlHttpClient;

use Facebook\Entities\AccessToken;
use Facebook\Entities\SignedRequest;

use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookOtherException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\GraphSessionInfo;



$session = $_SESSION['fb'] ;
file_put_contents('file.txt', serialize($session));
try {

    // Upload to a user's profile. The photo will be in the
    // first album in the profile. You can also upload to
    // a specific album by using /ALBUM_ID as the path
    $response = (new FacebookRequest(
            $session, 'POST', '/me/photos', array(
                    'source' => '@/var/www/website-root/images/add_more.png',
                    'message' => 'User provided message'
            )
    ))->execute()->getGraphObject();
    file_put_contents('files.txt', serialize($session));
    // If you're not using PHP 5.5 or later, change the file reference to:
    // 'source' => '@/path/to/file.name'

    //echo "Posted with id: " . $response->getProperty('id');

} catch(FacebookRequestException $e) {

    echo "Exception occured, code: " . $e->getCode();
    echo " with message: " . $e->getMessage();

}

解决方案

Finally, I figured out the way to achieve it. Now, I am using facebook javascript sdk with php sdk. Following is the process:

1)Get access token from javascript sdk(first file) and pass it to background along with the url of image/video. Code may be modified, if image/video is being uploaded through source.

2) php file(2nd file) containing function for executing backend-process(which is in third file) receives the posted data and and call the third file(in the form of url) and pass the data to it as well.

3) File(s) are uploaded to facebook through php sdk 4(third file)

Below is the code for first file containing javascript sdk code:

    <script> 

      (function(d, s, id){
         var js, fjs = d.getElementsByTagName(s)[0];
         if (d.getElementById(id)) {return;}
         js = d.createElement(s); js.id = id;
         js.src = "//connect.facebook.net/en_US/sdk.js";
         fjs.parentNode.insertBefore(js, fjs);
       }(document, 'script', 'facebook-jssdk'));
        window.fbAsyncInit = function() {
        FB.init({
          appId      : 'your app id',
          xfbml      : true,
          version    : 'v2.0'
        });
        FB.login(function(response){
            console.log(response);
            if (response.status === 'connected') {
                var data = new Array();

                alert('Logged into your app and Facebook.');
                //type: 0 for photo and type:1 for video. Create data array dynamically for real word applications
                data[0]= {url: 'http://url-of-video-file.mov',privacy : 'SELF', message: "title of video", type:1};
                data[1]= {url: 'http://url-to-image-file.png',privacy : 'SELF', message: "photo caption", type:0};
                $.ajax({
                    url: 'http://url-of-second-file/containing-code-for/backend-process',
                    data: {data: data, accessToken:response.authResponse.accessToken},
                    type: 'POST',
                    success:function(){
                        alert("photo uploaded");
                    }

                });


        },{scope:'email'});
    }

</script>

Now code of second file which receives data and execute back-end process:

<?php

//session_start();
ignore_user_abort(true);
set_time_limit(0);

function backgroundPost($url){
    $parts=parse_url($url);
    //print_r($parts);exit;

    $fp = fsockopen($parts['host'],
            isset($parts['port'])?$parts['port']:80,
            $errno, $errstr, 30);

    if (!$fp) {
        echo "test";
        return false;
    } else {
        $vars = $_POST;

        $content = http_build_query($vars);
        //file_put_contents('url.txt',$content);exit;
        $out = "POST ".$parts['path']." HTTP/1.1\r\n";
        $out.= "Host: ".$parts['host']."\r\n";
        $out.= "Content-Type: application/x-www-form-urlencoded\r\n";
        $out.= "Content-Length: ". strlen($content) ."\r\n";
        //$out .= "Cookie: PHPSESSID=" . $_COOKIE['PHPSESSID'] . "\r\n";
        $out .= "Connection: Close\r\n\r\n";
        if (isset($parts['query'])) $out.= $parts['query'];
        // print_r($out);exit;


        fwrite($fp, $out);
        fwrite($fp,$content);
        fclose($fp);
        return true;
    }
}
backgroundPost('http://link-to-third-file/containing-code-for-facebook-upload');

Now code of third file, which will actually upload the files. Please note, video files need to be downloaded before it can be uploaded.

<?php 

// start session
//session_start();
error_reporting(1);
ignore_user_abort(true);
set_time_limit(0);
@ini_set('display_errors', 1);


//include facebook library through autoload
require_once('facebook-4/autoload.php');

use Facebook\HttpClients\FacebookHttpable;
use Facebook\HttpClients\FacebookCurl;
use Facebook\HttpClients\FacebookCurlHttpClient;

use Facebook\Entities\AccessToken;
use Facebook\Entities\SignedRequest;

use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookOtherException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\GraphSessionInfo;

// init app with app id and secret
FacebookSession::setDefaultApplication('app_id','secret_key' );
$session = new FacebookSession( $_POST['accessToken'] );

foreach($_POST['data'] as $key => $data){
    if($data['type'] == 1){
        $ext = substr($data['url'],strrpos($data['url'],'.'));
        $file = '/path/to/temp/location/for/saving/video/'.time().$ext;
        if(file_put_contents($file,file_get_contents($data['url']))){
            try {

                // Upload to a user's profile. The photo will be in the
                // first album in the profile. You can also upload to
                // a specific album by using /ALBUM_ID as the path
                $response = (new FacebookRequest(
                        $session, 'POST', '/me/videos', array(
                                'source' =>  '@'.$file,
                                'title' => $data['message'],
                                'privacy' => json_encode(array('value' => $data['privacy'])),
                                'published' => true
                        )
                ))->execute()->getGraphObject()->asArray();

                // If you're not using PHP 5.5 or later, change the file reference to:
                // 'source' => '@/path/to/file.name'

                //echo "Posted with id: " . $response->getProperty('id');

            } catch(FacebookRequestException $e) {

                echo "Exception occured, code: " . $e->getCode();
                echo " with message: " . $e->getMessage();
            }
        }
    }else{
        try {

            // Upload to a user's profile. The photo will be in the
            // first album in the profile. You can also upload to
            // a specific album by using /ALBUM_ID as the path
            $response = (new FacebookRequest(
                    $session, 'POST', '/me/photos', array(
                            'url' =>  $data['url'],
                            'message' => $data['message'],
                            'privacy' => json_encode(array('value' => $data['privacy'])),
                            'published' => true
                    )
            ))->execute()->getGraphObject()->asArray();

            // If you're not using PHP 5.5 or later, change the file reference to:
            // 'source' => '@/path/to/file.name'

            //echo "Posted with id: " . $response->getProperty('id');

        } catch(FacebookRequestException $e) {

            echo "Exception occured, code: " . $e->getCode();
            echo " with message: " . $e->getMessage();
        }
    }
}
    ?>

这篇关于上传照片/视频Facebook的异步使用PHP SDK 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆