Connect to facebook api in blackberry - blackberry

i found an sdk here:
http://www.baskoro.web.id/facebook-connect-blackberry-HOWTO.html
i tried to run the code both on device and simulator but it shows only white screen and nothing else
i also tried this without result token:
.append("&next=http://www.facebook.com/connect/prompt_permissions.php?api_key=" + "api_key" + "&display=popup&v=1.0&next=http://www.facebook.com/connect/login_success.html?xxRESULTTOKENxx&fbconnect=true&ext_perm=read_stre...")
but no success
i also tried this without result token:
StringBuffer url = new StringBuffer()
.append("http://m.facebook.com/login.php?")
.append("api_key=")
.append(facebookFacade.getApplicationKey())
.append("&connect_display=page")
.append("&v=1.0")
.append("&fbconnect=true")
.append(
"&next="http://www.facebook.com/connect/login_success.html?xxRESULTTOKENxx&fbconnect=true"
);
i dont have result token
how to get that????
Plzzzzzzzz help

Please use the latest SDK at here instead. You should be able to follow the short tutorial on the same page as well.

Download graph api from http://sourceforge.net/projects/facebook-bb-sdk/.
After that you have to add two thinks.
one is when you want to post a photo to your friends wall ,you have to put one more key-value in the JSONObject(Request) - that is requestObject.put("target_id",getid()) in publisePhoto method facebookuser.java & facebook.java
Second is you have to change
JSONObject responseObject = fb.write(getId() + "/photos", requestObject, pPhoto.getMIMEType(), imageData, true);
to
JSONObject responseObject = fb.write(getId() + "/photos?access_token="+Facebook.token, requestObject, pPhoto.getMIMEType(), imageData, true);in FacebookUser.java & Facebook.java
where token is Static string from Facebook.java and store the value of access_token (you have to add it)

i think before you start with sample codes.
you need to study some of the links.
OAuth 2.0
facebook developer documents
after that you can get
client_id and client_secret from this link

Related

Changing CurrentAccessToken in Facebook Unity SDK

I'm trying to post to a Facebook page AS the page using the Unity Facebook SDK running on iOS. As I understand, to do that, I need the pages access token with manage_pages and publish_pages. I know that I can get it from /me/accounts?fields=access_token, but how do I tell AccessToken.CurrentAccessToken to use my pages access token instead?
Right now i'm using the following:
var wwwForm = new WWWForm();
//wwwForm.AddField ("access_token", "A-T I NEED");
wwwForm.AddBinaryData("image", screenshot, "InteractiveConsole.png");
wwwForm.AddField("message", "herp derp. I did a thing! Did I do this right?");
FB.API("/PAGE-ID/photos", HttpMethod.POST, HandleResult, wwwForm);
I tried putting the access token manually, but that didn't work (so I commented it out).
With this as it is I'm getting an error, telling me that I need publish_actions, wich is not correct since I'm not trying to post as the user. If I also get publish_actions the Post goes online, but is posted to the page as the user speaking. (User is also Admin)
Any Ideas ? Thanks!
So, I filed a bug report to facebook and as it turns out: "… at this time this functionality is not supported." Wich simply means there is now way to use the Page Access Token you acquired via the FB.API within the FB.API. And they are not going to tell you abot it in the documentation.
As a workaround I simply use a UnityWebRequest like this:
IEnumerator UploadToPage(byte[] screenshot) {
var wwwForm = new WWWForm();
wwwForm.AddField("message", "herp derp. I did a thing! Did I do this right?");
wwwForm.AddBinaryData("image", screenshot, "Test.png");
string url = "https" + "://graph.facebook.com/"+ PageID + "/photos";
url += "?access_token=" + PageAccessToken;
using (UnityWebRequest www = UnityWebRequest.Post(url, wwwForm))
{
yield return www.Send();
if (www.isError)
{
Debug.Log(www.error);
}
else
{
Debug.Log("Form upload complete!");
}
}
Debug.Log(url);
}

Create Snapshot/Thumbnail of a blog entry using mvc

I need to generate a snapshot from multiple links of blogs.
What i have is a list of text like these
"Report: Twitter Will Release Music Discovery App This Month http://on.mash.to/10L1v49 via #mashable"
I want to show the links as snapshot of the blog, followed by its text in my view. Or at least i need to get the picture attached to the blog.
Using facebook debug, http://developers.facebook.com/tools/debug ,i am getting this..
fb:app_id: 122071082108
og:url: http://mashable.com/2013/03/13/twitter-music-app/
og:type: article
og:title: Report: Twitter Will Release Music Discovery App This Month
og:image:
og:description: Twitter is planning to release a standalone music app for iOS called Twitter Music as soon as the end of this month, according to CNET. CNET reports that Twitter Music will help...
og:site_name: Mashable
og:updated_time: 1363267654
I tried the same link from my c# code, accessed the link with parameter 'q' as my desired link. I got the same html as reply but i am unable to find the image associated as it is coming differently for different links.
Can anyone suggest a better method to do this in mvc?
My code in controller to access facebook debug :
var client = new RestClient
{
BaseUrl = "http://developers.facebook.com/tools/debug/og/object"
};
var request = new RestRequest
{
DateFormat = DataFormat.Xml.ToString(),
Resource = "Add",
Method = Method.GET
};
request.AddParameter("q", "http://on.mash.to/10L1v49");
IRestResponse response = client.Execute(request);
var content = response.Content; // raw content as string
What i understand from your question is, you need something like the preview of a link what we get on pasting some link on facebook share area.
Facebook debug method returns an html page which has the image of your blog entry from the link given.
Use HtmlAgilityPack to parse your html returned from facebook debug
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(content);
HtmlNode root = doc.DocumentNode;
var imageurl = doc.DocumentNode.SelectNodes("//img/#src").LastOrDefault();
string imagesrc = imageurl.OuterHtml.ToString();
int start = imagesrc.IndexOf("url=");
int to = imagesrc.IndexOf("\"", start + "url=".Length);
string s = imagesrc.Substring(
start + "url=".Length,
to - start - "url=".Length);
string a = Uri.UnescapeDataString(s);
and..there you have your image of the blog entry. Same function can be modified to retireve the title, description and the updated time of the blog entry.

how to set permission of google doc using its api?

I am new to google doc api, and using google doc api 3rd version with java ,
I m trying to share doc with permission and want to change permission on different call,
Here there is some code which i had designed to share persmission and update and delete permission , but some how i wil got some problem on each operation,
On first time i can share docs with permission , but once i had share and again try to share with other permission then it cant allow me to upda so what should be i missing at here ,
AclEntry acl = new AclEntry();
AclScope aclScope = new AclScope(AclScope.Type.USER,"xyz#gmail.com");
acl.setScope(aclScope);
//AclRole aclRole = new AclRole();
acl.setRole(AclRole.READER);
URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED + "/" + folderResId + URL_FOLDERS + "/" + entry.getResourceId());
System.out.println(url.toString());
System.out.println("url : "+entry.getAclFeedLink().getHref());
// For Insert
//service.insert(new URL(entry.getAclFeedLink().getHref()), acl);
// For Update
//service.getRequestFactory().setHeader("If-Match", "*");
//service.update(new URL(entry.getEditLink().getHref()), acl);
// For Delete
service.getRequestFactory().setHeader("If-Match", "*");
service.delete(new URL(entry.getEditLink().getHref()), aclScope);
after insert first tim eif itry to insert again i wil get this error..
com.google.gdata.util.VersionConflictException: This user already has access to the document.
After insert if i try to delete that then i wil get this error
com.google.gdata.util.InvalidEntryException: Unexpected resource version ID
thnaks in advance,
Just a comment about your first error message: according to my experience with this api, this is the behavior that is in fact expected, as long as you are trying to insert an acl record that is equivalent to an already existent one. In other words, you can't insert a duplicate of an existing acl record, you always get that exception when you try to do so.

Facebook C# SDK MVC3

i am trying to get my facebook picture by calling :
var user = InMemoryUserStore.Get(User.Identity.Name);
var fb = new FacebookClient(user.AccessToken);
dynamic myPhoto = fb.Get("me/picture");
After the call i am receiving this exception message :
Invalid JSON stringStackTrace: at Facebook.FacebookClient.Api(String path, IDictionary`2 parameters, HttpMethod httpMethod, Type resultType) in d:\prabir\Documents\Projects\facebooksdk\v5.4.1\Source\Facebook\FacebookClient.cs:line 479 at Facebook.FacebookClient.Get(String path) in d:\prabir\Documents\Projects\facebooksdk\v5.4.1\Source\Facebook\FacebookClient.cs:line 184 at CS_AspNetMvc3_WithoutJsSdk.Controllers.FacebookController.Index()
i have tried to get the picture through graph api explorer and it works.
Are you familiar with this exception and how can i retrieve my picture?
I just ran into the same issue. As a workaround I used FQL to retrieve the picture:
dynamic result = fb.Query("select pic_small from user where uid = " + profileId);
For some reason the JSON serializer in the C# Facebook SDK is unable to deserialize the GET response for a picture. If you look closely at the Graph API explorer, you'll notice its not your regular JSON being returned..

Google OAuth 2.0 Response

I need help figuring out why my OAuth 2.0 response is always something like:
https://accounts.google.com/o/oauth2/approval?as=[BUNCH OF LETTERS AND NUMBERS]&xsrfsign=[BUNCH OF LETTERS AND NUMBERS]
This is the response after I login to my Google account and click allow access to the application.
It's nothing like the response I'm expecting according to the documentation (http://code.google.com/apis/accounts/docs/OAuth2WebServer.html#handlingtheresponse)
First of all, you did not specified the language you are coding.
Secondly, make sure you specify the corect RedirectUri. You can get or set if from google console (https://code.google.com/apis/console/).
Then, for this kind of url https://accounts.google.com/o/oauth2/approval?as=.....&xsrfsign=..... you won't get the authorization code from the url but from the content of the page:
I have extracted it from the raw code of the page: [C# code]
string []s=webBrowser1.Document.ActiveElement.InnerHtml.Split (new string [] {"value=\"", "\""}, StringSplitOptions.None);
string authCode=s[165];

Resources