久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Facebook:通過 php 將圖像和描述發布到墻和頁面相冊

Facebook: post image and description to wall and in page album via php(Facebook:通過 php 將圖像和描述發布到墻和頁面相冊中)
本文介紹了Facebook:通過 php 將圖像和描述發布到墻和頁面相冊中的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我希望用戶通過網站上的表單在 Facebook 頁面上發布圖片.當他們在本網站上通過 facebook 登錄后,他們可以從他們的電腦中選擇一張圖片.

I want users to post an image on a facebook page via a form on a website. When they have logged in via facebook on this website, they can select an image from their computer.

一旦他們選擇了圖像,我希望將其發布到用戶墻上,以及我是管理員之一的頁面的相冊中.

Once they have selected the image, I want it to be posted to the users wall, and in an album of the page where I'm one of the administrators.

我為此創建了一個應用程序,但我們似乎無法找到讓應用程序在此 facebook 頁面上發布的方法.

I have created an app for this, but we can't seem to find a way to get the app to post on this facebook-page.

我們需要為此頁面或應用設置任何權限嗎?

Do we need to set any permissions on this page or app?

推薦答案

要將圖像上傳到您是其管理員的 Facebook 頁面,您需要執行以下操作:

To upload images to a facebook page of which you're an admin you need to do the following:

1.) 創建一個 facebook 應用程序(通常的方式),確保你指定了 Canvas URL

1.) Create a facebook application (the usual way), make sure you specify the Canvas URL

2.) 導航到以下 url 以頁面管理員身份登錄,并授予權限 (user_photos,manage_pages,offline_access,publish_stream)

2.) Navigate to the url below logged in as the admin of the page, and give the permissions (user_photos,manage_pages,offline_access,publish_stream)

https://www.facebook.com/dialog/oauth?
    client_id=<application_id>
    &redirect_uri=<canvas_url>
    &response_type=token
    &scope=user_photos,manage_pages,offline_access,publish_stream

3.) 當您授予應用程序所需的權限時,您將被重定向到 canvas_url#access_token=*access_token*,例如

3.) When you give the application the required permissions you'll be redirected to canvas_url#access_token=*access_token*, for example

http://example.com/#access_token=awe12

4.) 然后導航到

https://graph.facebook.com/me/accounts?access_token=<access_token>

(使用 #3 中的訪問令牌).這將列出您管理的頁面;記下要上傳圖片的頁面的 access_token

(use the access token from #3). This will list the pages you administer; write down the access_token for the page(s) to which you want to upload the image

我不是 100% 確定,但我相信使用圖形 API 您只能將圖像上傳到通過圖形 API 創建的相冊;即您需要首先通過圖形 api 創建一個專輯.下面是使用 curl 的示例代碼:

I'm not 100% sure but I believe that using graph api you can upload images only to albums created via graph api; i.e. you need to first create an album via graph api. Here's sample code using curl:

$uri = sprintf( 
    'https://graph.facebook.com/%1$s/albums?access_token=%2$s',
    $page_id, 
    $access_token
);

$post_fields = array(
    'name' => trim( $album_name )
);

$curl = curl_init( $uri );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );  
curl_setopt( $curl, CURLOPT_POST, TRUE );
curl_setopt( $curl, CURLOPT_POSTFIELDS, $post_fields );  

$raw_data = curl_exec( $curl );
curl_close( $curl );

$data = json_decode( $raw_data, $assoc = TRUE );

上面的 $data 將包含相冊 ID,您需要上傳照片:

The $data above will contain the album id, which you'll need to upload a photo:

// prepare the curl post fields
$batch = sprintf(
    '[{"method":"POST", "relative_url":"%1$s/photos", "attached_files":"file1"}]',
    $album_id
);  

$post_fields = array(
    'batch' => $batch,
    'access_token' => $access_token,
    'file1' => '@' . $image_abs_path
);
$uri = 'https://graph.facebook.com';

$curl = curl_init( $uri );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );  
curl_setopt( $curl, CURLOPT_POST, TRUE );
curl_setopt( $curl, CURLOPT_POSTFIELDS, $post_fields );  

$raw_data = curl_exec( $curl );
curl_close( $curl );

$data = json_decode( $raw_data, $assoc = TRUE );

這篇關于Facebook:通過 php 將圖像和描述發布到墻和頁面相冊中的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 国产1区2区在线观看 | 青青草网| 久久久免费少妇高潮毛片 | 午夜视频大全 | 无码日韩精品一区二区免费 | 一区二区国产在线 | 伊人久久国产 | 亚洲综合成人网 | 欧美在线看片 | 日韩毛片在线观看 | 成人二区 | 国产精品毛片无码 | www久久国产 | 99re视频在线观看 | 一级aaaa毛片| 国产一区二区三区免费观看视频 | 北条麻妃一区二区三区在线视频 | 夜夜久久 | 黄色高清视频 | 久在线 | 日韩国产精品一区二区三区 | 美女毛片免费看 | 久久午夜影院 | 日本不卡一区二区三区在线观看 | 日韩中文字幕在线播放 | 成人在线观看免费观看 | 亚洲国产日韩一区 | 99精品网站 | 一本色道精品久久一区二区三区 | 日本一区二区高清不卡 | 亚洲成人综合在线 | 人人九九精 | 欧美一区久久 | 成人一区av | 青青草一区 | 91观看| 91色综合| 精品区一区二区 | 中文字幕视频在线看 | 成人av一区二区三区 | a级黄色片在线观看 |