Upload photo to facebook fanpage appcelerator titanium - facebook-graph-api

I have an app that lets me take a pic or choose from my gallery and upload it to my personal fb page.
How can I let it upload to my fanpage instead of my own page?
I use this for putting it in my page:
var data = {picture: image};
Titanium.Facebook.requestWithGraphPath('me/photos', data, "POST", function(e){
if(e.success) {
var d = Titanium.UI.createAlertDialog({
title: Titanium.App.Properties.getString("namn"),
message: 'Uploaded!',
buttonNames: ['Ok'],
});
d.show(); }
It wont just work to change the 'me/photos' to 'pageid/photos'.
What will I have to do to get it to work?
Thanx

As described under the photos secion in the Graph API Documentation for
Page
You should name the parameter source and not picture
Also, make sure you have the publish_stream and manage_pages permissions

Related

fb.ui feed dialog not working well on IOS

I used FB.ui to create a share dialog.
Here my coffeescript code:
FB.ui
method: "feed"
link: "facebook.com"
, (response) ->
if response and response.post_id
console.log("shared")
It works well on desktop browser and android but it doesn't work well on IOS (Safari & Chrome).
Problem is:
when i didn't sign in my facebook account and then I click share, it will redirect to new tab and request to login, after that I can share.
but when my facebook account sign in ready and then I click share, it doesn't show share dialog. it show only blank page.
Anyone ever meet this? How can I solve this???
Try add this to the code:
display: 'touch'
I was using
FB.ui(
{
method: 'share',
href: url,
mobile_iframe: true
},
function(response){
document.location.href = url;
});
But didn't work on iPhone so I decided to redirect the browser to the share url of Facebook like this:
document.location.href = 'https://www.facebook.com/dialog/feed?app_id=APPID&display=popup&&link=https%3A%2F%2Fyourdomain.com%2Furl&redirect_uri=https%3A%2F%2Fyourdomain.com.com%2Furl
Keep in mind that for : the code is %3A and / %2F. You will have to replace as such for it to pick them up.
Hope it helps

Share multiple videos on one page onto facebook page wall

I'm using Facebook C# SDK to post on fan page wall. (I created FBApp ext...) and using FB connect (Javascript) to user login, with this scope - "publish_actions,manage_pages,publish_stream". after user login i got an access_token to post on the page.
I have a page, and on the page settings "Everyone can add photos and videos to Testpage's timeline" is checked.
I can post message and picture, but when i tried to post a video (Youtube URL), it's appears on section "Recent Posts by Others on Testpage". When the Everyone can add photos and videos to Testpage's timeline" is not checked, I don't see any post.
To post a video on page, I must enabled "Everyone can add photos and videos to Testpage's timeline"?
When i success to post a video, Why the video appears on "Recent Posts by Others on Testpage"?
My Facebook user is admin on the page and I'm login with this user.
Thank's
To do this, you need to get the access token from the user accounts, and not from the FB.Login.
string getPagesTokensUrl = string.Format(#"https://graph.facebook.com/me/accounts?access_token={0}",accessToken);
using (WebClient wc = new WebClient())
{
var pagesTokens = wc.DownloadString(getPagesTokensUrl);
JObject o = JObject.Parse(pagesTokens);
for (int i = 0; i < o["data"].Count(); i++)
{
if (o["data"][i]["id"].ToString() == ConfigurationManager.AppSettings["YOUR PAGE ID"])
{
return o["data"][i]["access_token"].ToString();
}
}
}

FB.api doesn't bring profile name

I am using Facebook JS sdk to show news feeds. the app works well for many users for for some users who have authorized my app doesn't bring reasonable result.
I use following code to get basic profile info which works for some users but for some it doesn't:
FB.api('/' + id + '?access_token=' + access_token, function (response) {
var strTitle = response['first_name'] + " " + response['last_name'];
});
In response object I receive only id, birth date, email, profile link but name is not available. Interestingly when I open profile link in my browser facebook says:
"Sorry, this page isn't available
The link you followed may be broken, or the page may have been removed."
after that my code can bring its posts but again the from name of the posts is missing in response object. The permissions list is attached as picture.
I can't understand what is going on and how can i fix this issue. Any help please?
The problem is that you are using the App center permissions feature (previously known for Authenticated referrals).
Use these settings to enter the set of permissions your app requires when displayed in App Center
You should be passing a login url with the scope array of permissions in JS SDK.
FB.login(function(response) {
// handle the response
}, {scope: 'email,user_likes'});
or via a login button
<div class="fb-login-button" scope="email,user_likes" data-show-faces="true" data-max-rows="3">Login with Facebook</div

Avoid user login for facebook feed dialog using FB - JS SDK

I have a Rails 3.2 app that uses omniauth gem to authenticate users via Facebook. Once the user is authenticated, i save his FB user_id and access_token that is generated.
I used fb_graph gem to allow users post directly to their friends wall via our app. But recently FB has removed the support of posting to friends wall using their Graph API. This has broken my feature of posting to friends wall using fb_graph gem.
Their documentation says we can post to friends wall via Feed Dialog. Following is the code I wrote for feed dialog:
<p><a onclick="launchFeedDialog(); return false">Testing the Feed Dialog</a></p>
<script>
function launchFeedDialog() {
// calling the API ...
var obj = {
method: 'feed',
to: 'RECIPIENT NAME', // Can specify recipient here
link: 'http://example.com',
name: 'Test post',
description: 'Test description'
};
FB.ui(obj);
}
</script>
When I click on the link, it opens FB dialog asks user to login. I need to avoid this as I have already authenticated the user via FB and have his access token. On clicking the link it should ask user to type message and not ask for user credentials.
How can I do this?
Thanks.

Graph API equivalent for sharing photo?

Trying to create a wall post with photo attached. Photo is a Facebook-hosted photo within some album.
Problem here - Facebook won't allow including facebook-hosted content in posts ((#100) FBCDN image is not allowed in stream )
From the Web UI, it's possible to "Share" a photo on my wall - that's almost what i need but i don't know the Graph API equivalent for that operation (if there's any)
Any help appreciated.
The answer is "me/links"
passing http://www.facebook.com/photo.php?fbid=** as a link
With the Graph API you can share the photo as a link.
this is the documentation:
https://developers.facebook.com/docs/reference/api/user/#links
You need send a POST request to me/feed/. And indeed send the link: http://www.facebook.com/photo.php?fbid=[the id of the photo]
Make sure the publish_stream permission is allowed for the access_token.
with Jquery this is an example:
$.post(
'http://www.facebook.com/me/feed',
{
link: 'http://www.facebook.com/photo.php?fbid=[THE_PHOTO_ID],
access_token: [YOUR_ACCESS_TOKEN]
},
function(result) { console.log('shared'); },
'text'
);