作者oToToT (屁孩)
看板Ajax
標題[問題] facebook分享圖片
時間Fri Aug 15 18:32:00 2014
我想要將我網頁中canvas做出來的圖分享到FB,所以先將canvas base64後傳到imgur再用
imgur的連結讓他分享到FB中。而權限的部分我只有拿publish_actoin跟public_profile
但是每次shareToFB()的時後,他總會出現紅紅的字...而且好像非管理員連用都不能用..
請問大家有解嗎?
網站:
http://ototot.github.io/ToS_Card/
這是部分縮減過的code:
function shareToFB () {
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
//已登入且和app連結
var uid = response.authResponse.accessToken;
accessToken = response.authResponse.accessToken;
init();
} else if (response.status === 'not_authorized') {
//已登入但未與app連結
login();
} else {
//未登入
login()
}
});
}
function login() {
FB.login(function(response) {
if (response.authResponse) {
init()
}else{
//somethibg
}
}, { scope: 'public_profile,publish_actions' });
}
function init () {
var link = ""
var imgURL = ""
$.ajax({
url: '
https://api.imgur.com/3/image',
headers: {
'Authorization': 'Client-ID e51ef6bcc76b94e'
},
type: 'POST',
data: {
'image':
get("output").toDataURL("image/png").replace("data:image/png;base64,","")
},
datatype: 'JSON',
success: function(req) {
imgURL = req.data.link
link = req.data.deletehash
FB.api('/me/photos', 'post', {
access_token: accessToken,
message: get("pd").value,
url:imgURL
}, function(response){
if (!response || response.error) {
//Something
} else {
//something
}
});
}
});
}window.fbAsyncInit = function() {
FB.init({
appId: XXXXXXXX,
status: true,
cookie: true,
xfbml: true,
oauth: true,
version: 'v2.0'
}
);
}
function shareToFB () {
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
//已登入且和app連結
var uid = response.authResponse.accessToken;
accessToken = response.authResponse.accessToken;
init();
} else if (response.status === 'not_authorized') {
//已登入但未與app連結
login();
} else {
//未登入
login()
}
});
}
function login() {
FB.login(function(response) {
if (response.authResponse) {
init()
}else{
//somethibg
}
}, { scope: 'public_profile,publish_actions' });
}
function init () {
var link = ""
var imgURL = ""
$.ajax({
url: '
https://api.imgur.com/3/image',
headers: {
'Authorization': 'Client-ID e51ef6bcc76b94e'
},
type: 'POST',
data: {
'image':
get("output").toDataURL("image/png").replace("data:image/png;base64,","")
},
datatype: 'JSON',
success: function(req) {
imgURL = req.data.link
link = req.data.deletehash
FB.api('/me/photos', 'post', {
access_token: accessToken,
message: get("pd").value,
url:imgURL
}, function(response){
if (!response || response.error) {
//Something
} else {
//something
}
});
}
});
}window.fbAsyncInit = function() {
FB.init({
appId: XXXXXXXX,
status: true,
cookie: true,
xfbml: true,
oauth: true,
version: 'v2.0'
}
);
}
function shareToFB () {
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
//已登入且和app連結
var uid = response.authResponse.accessToken;
accessToken = response.authResponse.accessToken;
init();
} else if (response.status === 'not_authorized') {
//已登入但未與app連結
login();
} else {
//未登入
login()
}
});
}
function login() {
FB.login(function(response) {
if (response.authResponse) {
init()
}else{
//somethibg
}
}, { scope: 'public_profile,publish_actions' });
}
function init () {
var link = ""
var imgURL = ""
$.ajax({
url: '
https://api.imgur.com/3/image',
headers: {
'Authorization': 'Client-ID e51ef6bcc76b94e'
},
type: 'POST',
data: {
'image':
get("output").toDataURL("image/png").replace("data:image/png;base64,","")
},
datatype: 'JSON',
success: function(req) {
imgURL = req.data.link
link = req.data.deletehash
FB.api('/me/photos', 'post', {
access_token: accessToken,
message: get("pd").value,
url:imgURL
}, function(response){
if (!response || response.error) {
//Something
} else {
//something
}
});
}
});
}
--
我還沒說完吶~~ 夠多了夠多了,回家啦~!
\ /
○
︵ \○╱/|
. . ﹎ ﹍﹍ ╱ ̄﹚╱> (原PO被拖走了....)
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.193.74.170
※ 文章網址: http://webptt.com/m.aspx?n=bbs/Ajax/M.1408098728.A.2FF.html
1F:推 qwer820404: 我記得4/30之後的APP 使用額外權限要送審... 08/16 00:19
2F:→ qwer820404: 基本的三個 email public_profile user_friends 08/16 00:20
3F:→ qwer820404: 其他都要在APP的Status&Review下面 去submission 08/16 00:21
嗯哼...送審了,但怎麼不過啊,我已經按照他說的填啦...
Please explain how you are using publish_actions to enhance a person's in-app
experience:
中文:
這個APP能讓使用者簡單的做出專屬於他們的神魔之塔卡片。而當做完時,可能他們會想要
將卡片跟他的朋友們炫耀,所以我覺得將卡片的圖發佈到Facebook是個不錯的選擇。
English:
This app is an easy way to let user make their own "Tower of Saviors" card,
when they got their own card maybe they'll want to show off to their friends,
so I think post the card image to their Facebook is a good way.
Please provide step-by-step instructions so our review team can reproduce how
you are using publish_actions in your app.
1. Go to http://ototot.github.io/ToS_Card/.
2. Make your own card.
2. Click the "分享至FB" button.
3. Enter what you want to post
4. Click the "分享" button.
5. Accept the "publish_actions" permission.
The card is published on your timeline.
To add a photo of the card you want to have:
1. Click the middle of card.
2. Select a photo.
※ 編輯: oToToT (123.193.74.170), 08/16/2014 13:32:00
4F:推 hit1205: 審核期要三天,而且他會告訴你結果 @@ (如果失敗也會說 08/17 22:07
5F:→ hit1205: 原因 08/17 22:07
6F:→ oToToT: 他有說原因...但說啥我沒用到權限 08/18 22:54