Post video to wall from IOS, through server - facebook

I've done a fair bit of searching for this, but can't seem to find an answer for this specific problem. I'm fairly new to web development as well, so forgive me if the answer is right in front of my eyes.
I have an IOS app which needs to allow a user to post a video to his FB wall, which is created from content the user creates from within the app.
However, the rendering of the video is too processor-instensive for the device itself, so I'm hoping to do something like the following:
Allow the user to authenticate the post, using the IOS login.
When this happens, ipload an xml file to a remote server which has all the data needed to render the video.
This server is running a custom app which will render the video and then complete the post operation, uploading the video with the user's credentials and posting it to their wall.
Is this possible? If not, can anyone suggest alternatives? Maybe I could host the file somewhere else and then simply post a link to it on the wall directly from the app?
Thanks in advance.

Sounds like this tutorial is what you want:
How-To: Use the Graph API to Upload a Video (iOS)
You'll obviously have to tweak it since you're doing the upload server side, but should be able to figure that out. The basics you'll needto do:
have the iOS app log the user in and grant the correct permissions
after login, keep track of the user's facebook access token
When submitting the video-generation request to your server, include the user's access token
When the server is ready to post, it uses that access token to post on the user's behalf.

Related

How to use Google Api to upload to a single Youtube channel on a User-less app

I'm building an app that will allow users to upload videos to my Youtube channel. I have checked online about using Google Api to access the data/upload videos, but all references and examples seem to assume videos will be uploaded to the user's youtube channel, hence the process always involves using OAuth to gain approval from the user.
However, in my case the only youtube channel all users will access is mine. And I'm not even asking them to create an account on my app to upload the videos. Is there a way to do this directly from the app.
My app is an iOS app, but if you have a solution in any other language, I welcome your suggestion.
Thanks in advance
I had the same problem not so long ago. Youtube Documentation doesnt make it easy. Even though you getting access to your own Youtube channel, You still need to be authenticated using OAuth. Google makes hard for you to be vulnerable to attacks.
My solution is using a server side(API) application. What you can then do is make your iOS app hit the API.
So the tricky thing is getting the refresh token. Its hardly documented anywhere. What you can then do is follow documentation of your preferred language for the API.
The documentation can be found here https://developers.google.com/youtube/v3/guides/auth/server-side-web-apps
Get the Refresh token:
Step 1 : Hit this url in the browser https://accounts.google.com/o/oauth2/auth?client_id=ClientID_Here&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://gdata.youtube.com&response_type=code&access_type=offline
It will make you log in using your youtube credential which is your google account.
You will then have to agree for google to access your account by clicking allow.
At the end it will give you a code.
Step 2 : You should then authenticate using a clientless platform.
(eg instead of browser) Use curl instead. (There plenty of 3 minute tutorials on how to use curl)
Hit this url endpoint :
curl https://accounts.google.com/o/oauth2/token -d "code=CodeFromGoogleOAuth&client_id=ClientIDHere&client_secret=ClientSecretHere&redirect_uri=urn:ietf:wg:oauth:2.0:oob&grant_type=authorization_code"
You should then get a refresh token in the response.
There are alot of examples of how to upload from then on like
https://developers.google.com/youtube/v3/code_samples/dotnet
In the example above you have to avoid using the GoogleWebAuthorizationBroker use Googles one instead. Look for RefreshToken Field
It is not possible to allow third parties to upload videos to a single YouTube account with the YouTube Data API, and that is by design. See this Google Blog, explaining "It’s tempting to design a system in which all videos are uploaded to a single “master” YouTube account, but this is always the wrong approach."
A potential workaround is to use YouTube Direct Lite, which allows you to easily build and moderate a playlist on your YouTube account comprised of videos uploaded by your users on their accounts.

Should Facebook canvas apps behave same if opened from original non-canvas site url?

This is a first time I am trying to make a facebook application/game, and I have couple of questions.
Let's say canvas url is http://mysite/first_app/ and facebook app url is https://apps.facebook.com/first_app
I wonder if visited both url-s should a functionality be the same? I mean does facebook give you more tools and freedom if navigated from https://apps.facebook.com/first_app? Or should both url-s look and do the same thing? Is it possible?
I wonder if visited both urls should a functionality be the same
Of course yes. The difference is just that one is deployed at the facebook's app center and the other at your domain.
Yes, you have more tools available in the canvas ("apps.facebook.com.."), as it will send you the user-id without any user consent. Has the user previously used your app, you will also be able to get their accesstoken and fetch more info about them.
It requires some backend code to decode the signed request parameter, which provides you this stuff.
This example is how php handles signed request:
https://developers.facebook.com/docs/facebook-login/using-login-with-games/
If you're using C#, download the Facebook C# (available through NuGet, the package from Outercurve Foundation) and use this example:
How do I parse a signed request in Facebook C# SDK?
I try to handle the user in Facebook context whenever possible. It adds trust and more tools. Although since the Facebook phone/tablet app (App Store/Google Play) doesn't support Facebook apps at all, I often optimize the app for mobile web use also. I read somewhere that over 50% of daily Facebook visists are done using the phone app, so it might be something to think into your app while developing.
UPDATE:
I can see I have misunderstood part of signed request, as commented by Shadowfax and CBroe. In my app, I use the user id from signed request but of course only when the user has already logged on to the app beforehand. My apologies.

Can track belong to the application and not individual users?

My application isn't going to be revolved around soundcloud users, I will be using it for its nice api that is provided to stream audio. I also want to use the javascript upload feature but that seems to be out of the question too.
The record widget should be able to upload the audio to your server so that you can upload the audio not as an individual user.
I still haven't been able to get my app to work without using their authentication window.
Any help would be appreciated.
Nearly everything you do with the SoundCloud API must be done on behalf of a SoundCloud account. You can only use the SoundCloud API to stream content from or upload content to a SoundCloud account.
If you'd like to have SoundCloud functionality in your app, I'd recommend allowing users to connect their SoundCloud accounts.
"Authenticating without the SoundCloud Connect Screen", from the API docs: http://developers.soundcloud.com/docs/api/guide#user-credentials
With this method you can log in as a user in the code. Since every app must be registered to a user anyway, you can make a new username to register the app, and log in with that one.

How to setup Facebook Timeline Cover Photo auto upload in website?

I am new to Facebook API and app development. I am trying to build a facebook timeline cover website where users can auto upload and publish the cover to a new album created in the website/app name. Then they would be redirected to another page on my website with instructions on how to setup the cover on their profile timeline. Most profile cover websites are using the same method such as myfbcovers.com, facebookprofilecovers.com, profilephotocovers.com, facebook.coversdaddy.com, fbcoverlover.com and newfbcovers.com to name a few. I have been searching the facebook developer pages and several tutorials over the net. Some tutorials I checked are:
http://thinkdiff.net/facebook/graph-api-iframe-base-facebook-application-development/
http://daipratt.co.uk/facebook-api-upload-photo/
http://developers.facebook.com/blog/post/498/
And also several youtube videos.
But there are several confusions I have about the app. Sorry for the questions if they are too basic as I am a complete newbie who is willing to learn. One of the main problems is that most of the tutorials are outdated as the facebook app creation page etc. Now is different and there is no callback url etc. or canvas etc. in options now which are used in the tutorials. In the tutorials, it is mentioned that for creating a website app or facebook app for page, I need a callback URL which I cannot see now. Secondly, if it is mentioned in those tutorials that I need SSL in my website for an app but none of the facebook cover websites listed above have SSL it seems. I also do not have SSL on my server. So, not sure if that is needed and if an app is needed at all on my local server. And all the apps are doing things different such as I can see these URLs on clicking on some of the clickable links for uploading the cover button. Here are a few examples:
http://facebookprofilecovers.com/wp-content/themes/fbcovers/fb/?i=http%3A%2F%2Ffacebookprofilecovers.com%2Fwp-content%2Fuploads%2FHappily-Married-Facebook-Timeline-Cover.png
http://freetimelinecovers.net/facebook/?cov_img=/images/sports-covers/manchester-united.jpg
Some have direct link to the facebook app page such as:
http://apps.facebook.com/profilephotocovers/index.php?id=35 broken link
And only one website seems to have the publish_stream etc. in the url itself
https://facebook.com/dialog/oauth?client_id=162046520556852&redirect_uri=http%3A%2F%2Ffacebook.coversdaddy.com%2Fi-m-not-a-monster-1242.html&state=e4abcdc1d9288be8233a7ac4aa243997&scope=user_photos%2Cpublish_stream
On checking through Live HTTP header, it seems all websites are following a similar pattern which is directly used in the URL in the last website. For example, here are a few steps of the other websites I saw while checking with Live HTTP header.
https://graph.facebook.com/oauth/authorize?client_id=112308188876405&redirect_uri=http://www.myfbcovers.com/oauth/callback&scope=publish_stream,user_photos,email
https://facebook.com/dialog/oauth?client_id=237897089598589&redirect_uri=http%3A%2F%2Ffacebookprofilecovers.com%2Fwp-content%2Fthemes%2Ffbcovers%2Ffb%2Findex.php&state=0ca1581f006bdd80bd5da78e95179f3a&scope=publish_stream
And so on.
I could also notice that almost all websites were taking auth for only publish_stream and nothing else. Only myfbcovers.com is an exception which also asks for user_photos and email. Rest are not asking for the same and so perhaps publish_stream is the only permission needed.
So, to create the app is there any tutorial. And do I need to host the app on my own server in a sub directory of the website or does it make direct call to facebook. The reason I am asking is because it seems Facebook apps if hosted on local server needs SSL mandatory whereas none of the above websites have SSL/https. And if I do not need to host the app on my own server then how can I make the photo upload link to facebook and then return back to the website for the rest of the instructions. I am using Wordpress on my website like most of the other sites are doing and so, that should not be a problem I suppose. Any help would be highly appreciated. I am willing to learn properly and some good tutorials for creating the photo album and then uploading the photo to the user's album etc. would be fine too if not with the full code. Any help would be highly appreciated.
NOTE: I have removed the HTTP and WWW part in many of the above URLs as I can only post a maximum of two links being a new user. Please add them if needed in those where they are not present.
Ok, I did not install all the applications above to see exactly what they did. I think your question is long... but pretty straight forward. This is what I understand your question to be :
You would like to create a cover photo generator that will allow users to customize their cover photo by uploading files, maybe doing some editing to them. Also maybe using templates of cool ideas and in the end being able to update their cool new cover photo directly into their profile.
This is not very complicated to do although to this date there is no real documentation (by facebook) about how to dynamically update the cover photo. However there are ways of creating photo albums and uploading photos to there.
If you are planning to make your application run with in facebook - that means use the apps.facebook.com/your_app_name, and have canvas or tab URLS, then you will have to purchase an SSL certificate.
Finnaly, in order to get as close to the functionality your want, you might have to make some sacrifices (becuase changing the cover photo is not possible yet with the Graph API).
To locate the cover photo album you'll have to manually scan through all the users albums names - and for that you'll need the user_photos permission.
Once you have created the photo you want, you could possibly let the user upload it (publish_stream permission needed for this) to a different album, and then give the user some detailed instructions using screen shots and direct them exactly how to change their cover photo.
I recommend you read through the Authentication documentation decide what permissions you need (such as user_photos for the users photos and publish_stream for uploading a new picture or creating an album.)
In addition, there are many many tutorials on the Official Facebook Documentation Pages and their Developers Blog- check them out before going onto other sites that have written their own tutorials. Facebook does update their API quite a bit - but they also (recently) have been pretty good on updating their documentation to mirror the changes to the API...
As serious developers using a 3rd party API (
Graph API ), it is solely our responsibility to keep up to date with changes and to write code and applications that comply with their platform policies.

iOS Facebook Integration

I am working on simple facebook integration that allows users to post high scores to their wall. The way doodlejump handles this is my inspiration. I have it functioning, but it's not very clean and I'm not sure what to do.
I followed the instructions at http://developers.facebook.com/docs/guides/mobile to get up and running. One of the first things it has you do it call [facebook authorize:nil delegate:self]. After that you can call [facebook dialog:#"feed" andParams:params andDelegate:self] to make a post to the users wall. I have two issues with this.
First, when you call authorize it exits your app as that is facebook's new desired methodology as part of "One Single Sign-On" (OSS). That ok, what isn't ok is that my app is doing this even if the user is already signed on. I do not see a way to check if the user is already signed on.
The second issue is that it exits my app to authorize my app to post something to facebook. It seems acceptable to exit the app to sign on to facebook. Most users will have already done this, so no big deal. But my app should not have to exit just to get user authorization to post something. DoodleJump doesn't do that but I'm not sure how.
I tried digging through old posts but the SDK has changed so a lot of them are no longer valid. Thanks.
Based on the latest Facebook SDK (located at Github) and it's example I have determined that this is the expected behavior.
It is built around the new fangled "fast app switching" so it looks like that is just what happens.
A little lame imo but if that's what Facebook engineers have determined to be the optimal process then so be it.
I was having the same problem. Turned out it was because I hadn't set the URL Schemas in info.plist Where it says to fut fbYOUR_APP_ID make sure that you do this how they say. Your plist file should say something like fb12345 and then it will identify that the user has logged in correctly. offline_access will then work as a result
Might not be the answer you are looking for, but the app 'Hipstamatic' connects with facebook for photo upload (which I assume/hope is a similar process as wall posting) from within itself.
It could be worth seeing if they would be able to guide you if you sent the devs an e-mail?
I think they solve this issue by calling an iframe of sorts within the app, connecting the app to facebook and performing facebook activities, then closing once complete.
Hope this helps!
What permissions are you requesting? If you don't ask for offline_access the framework will make the user log in each time.
You can also try ShareKit
It's an open source library for iOS to share links, images and more. It's very simple and also works with Twitter and other social networks.
The site also contains some video tutorial and some code examples to integrate the Facebook API, Check this