Publishing on Facebook user's wall - facebook

i am developing an appon blackberry platform in which i hve to publish a message on users wall...i am able to get session id...but dont know how to proceed further...
i am doing something like this...
enter code here
URLEncodedPostData post = new URLEncodedPostData(URLEncodedPostData.DEFAULT_CHARSET, false);
post.append("method", "stream.publish");
post.append("message", "published through the Facebook API");
post.append("session_key", sessionKey);
post.append("attachment", null);
post.append("action_links", null);
post.append("target_id ", null);
post.append("uid ", null);
i am sending this as post data to following url :
http://api.facebook.com/restserver.php?
and the response i am getting contains :
101
Invalid API key

You should try to register your application, get API key and use in in requests.
Register and go www.facebook.com/developers/createapp.php

Related

Not able to fetch the data for G+ using gigya

We have created the gigya account. Using the same gigya account we have created the Twitter, facebook & G+ account(Reference : http://developers.gigya.com/010_Developer_Guide/82_Socialize_Setup/005_Opening_External_Applications/16_Google).
We are able to get the user & there friends info using gigya for FB & Twitter, however we are not able to get the users and there friends info using gigya for G+ account.
We have checked that G+ account set properly(As we are able to get the G+ account info using G+ API).
Can anyone help us to resolve the issue(why we are not able to fetch the data for G+ account)
Code Snippet :
GSRequest request = new GSRequest(apiKey, secretKey,
"socialize.getFriendsInfo", false);
request.setParam(Parameters.uid, uid);
request.setParam(Parameters.format, "json");
GSResponse response = request.send(timeout);
String response_json = response.getResponseText();
System.out.println("Friends Info : ");
System.out.println("#### "+response_json);
Output :
Friends Info : Getting an blank friend list array ...
{ "friends": [], "oldestDataUpdatedTimestamp": 0, "oldestDataAge": 3417602649, "statusCode": 200, "errorCode": 0, "statusReason": "OK", "callId": "d383b76ff5ab4822899577f9cd15f3ea"}
Similarly for profile details : Not getting basic details like nickname & other attributes...
Thank you in advanced
On the Gigya API key you are testing with, in the Gigya Console to to the Settings >> Permissions screen and make sure to check the "Enable extended social functionality (including access to Google+ circles)" permission. Then try logging back in again using the showLoginUI with the G+ user you are calling getFriendsInfo for. The next time you call getFriendsInfo it should return the friends information.
If that still doesn't work, try it with a new G+ user who hasn't signed into that API key before.

deleting facebook requests

The facebook docs here say "it is the Developers' responsibility to delete a Request once it has been accepted". As far as I understand, when someone sends a request to multiple users on facebook like this:
function sendRequestViaMultiFriendSelector() {
FB.ui({method: 'apprequests',
message: 'test message'
}, requestCallback);
}
only one request_id is returned via requestCallback() function.
Then, if I delete the request when someone accepts it, how would other users accept the deleted request?
when user comes following the app request, you can get request id's using
$_GET['request_ids']
then retrieve all the request ids with which you can call graph api to delete the corresponding requests like below:
if(isset($_GET['request_ids']))
{
$request_ids = $_GET['request_ids'];
}
$request_ids = explode(",", $request_ids);
foreach($request_ids as $request_id)
{
$full_request_id = $request_id."_".$fbid; //$fbid is current user facebook id
$facebook->api("$full_request_id","DELETE");
}
Check out the Request ID Format section of the FB request overview page.
The actual graph path for a request actually sent to specific user is "request-id"_"recipient-user-id".
you can access to facebook on mobile mode (m.faceook.com)
1-access the invitation panel
2-display all the invitations
3-open console mode in chrome
4-activate jquery by cpying and pasting all the jquery.min code into console
and excecute this script :
$("._54k8._56bs._56bt").trigger("click");
that will cancel or the invitation sent

j2me facebook graph api - posting image on a user wall

I'm trying to post image from device on user's wall. I have found: http://codenameone.blogspot.com/2011/09/lwuit-and-facebook-api-by-chen-fishbein_18.html, but it doesn't support post image, so I wrote a simple method like this:
public void postOnWallWithPhoto(String userId, String message, byte[] img) throws IOException {
checkAuthentication();
FacebookRESTService con = new FacebookRESTService(token, userId, FEED, true);
con.setContentType("image/jpeg");
con.addArgument("message", message);
con.addArgument("type", "photo");
con.addArgument("picture", img);
if (slider != null) {
SliderBridge.bindProgress(con, slider);
}
for (int i = 0; i < responseCodeListeners.size(); i++) {
con.addResponseCodeListener((ActionListener) elementAt(i));
}
current = con;
NetworkManager.getInstance().addToQueueAndWait(con);
}
This method is called in this way:
FileConnection fc = (FileConnection) Connector.open(path);
InputStream is = fc.openInputStream();
byte[] b = new byte[(int) fc.fileSize()];
is.read(b);
FaceBookAccess.getInstance().postOnWallWithPhoto(me.getId(), "test2", b);
After I send request, on a wall appears only text (in this example test2). In place where should be an image, there is a message: "invalid invalid".
Does anyone have idea, what I'm doing wrong? Or can someone share with me a code that will help me in posting images on a facebook wall?
The old LWUIT facebook login no longer works properly due to changes made by facebook to their login process.
This only works with Codename One which also supports image posting in its current facebook demo.
As we all know J2me does not provide with any in api for facebook support but there is a way we can still post images on facebook wall and i have done that.
Below i am sharing a breif procedure of how we can post images to facebook wall using j2me.
Get the ACCESS TOKEN from from facebook: You can do it using PHP or any third party api for getting it done(in my case i used app42(shephertz) cloud services)
Once you have the ACCESS TOKEN use that access Token to get the facebook userid on which you want to post the image.
And once you have the userId only thing left is to upload the image to facebook using 'MultiPart Request'. Below are some important statements from my code(I am not sharing my whole code because i have used third party api(app42) to get the access token and user id).
Url for facebook:
String url = "https://graph.facebook.com/" + user_id + "/photos?access_token=" + accessToken;
image stored in byte array : byte fileBytes[];
HashTable used in multipart request(you can copy it as it is):
Hashtable params = new Hashtable();
params.put("custom_param", "param1");
params.put("custom_param2", "param2");
A class that is sending my multipart request
HttpMultipartRequest req = new HttpMultipartRequest(url, params, "upload_field", "original_filename.png", "image/png", fileBytes);
you can use the following link to refer Multipart request
http://www.developer.nokia.com/Community/Wiki/HTTP_Post_multipart_file_upload_in_Java_ME
And once you are done with it i hope u might have successfully posted an image on facebook wall.
Happy Coding..

Titanium.Facebook getting graph api access token

I'm developing an iPhone app with Appcelerator Titanium SDK 1.6.2
I am upload an photo to a users facebook album with the Titanium Facebook module, graph api.
The upload goes just fine and returns the items unique ID.
When I try to parse the JSON from the unique id I'm told i need to pass an access token, which makes sense.
How do I get the access token to be passed to the graph request url?
When I do a XHR GET request while passing Ti.Facebook.accessToken I get the following error
URL: https://graph.facebook.com/10150527948301195?access_token=t4CqzHallahfy4d7RnERrJb4ffOkQfJvrYrGEBoZ4so.epdiI6IjJGR2ZFY1ZTMHh6RlR6ZmNIcVctMHcifQ.NBRMth0vb7pXKcd8lHNz9aremoyNpvrbhz2P3zkgWJU4eHdfewOp1WruBNZS_lSDy0XM0Xu0ACry8aEmSckGJVQJxEioykrNZhT7S9mJG2OKWqMdk6ucg5IMhXMfndF9sdKwWrWb7uPKI57LzIOf5lvA
{
error = {
message = "Unsupported post request.";
type = GraphMethodException;
};
}
And if I don't pass Ti.Facebook.accessToken I'm asked for it.
I'm bound to be missing something, any help would be greatly appreciated.
see this link http://developer.appcelerator.com/blog/2011/02/facebook-module-changes-in-titanium-mobile-1-6-0.html
I think you should be using Titanium.Facebook.requestWithGraphPath(...)

Facebook status update with PHP

My requirement was to update members status from my site, i am also thinking about displaying their friends photos and their last status update.
I have looked all over the docs and cant decide which works for my need. RESTful API, JavaScript API, FQL, XFBML, FBML, FBJS ?? whcin one works best? or best way?
It should be like, when they first go to the page,there will be nothing but a login option. when they click on it, a pop up should appear and when they are authorized, we display a text area to post update. Here, i wanted to show their friends pics too
when they came back later, they should able to post right away, must not ask for login again.
Can some one help me with the code?? I dont expect you to write everything, get the friends pic and their last update into a PHP array would be nice.
Many thanks
If u need to update users data stored at ur database so u will use the facebook API to check user signed in and get his data. i have an ifram application at facebook and i am using C# code (asp.net application) and when the user request the application i authenticate that he is signed in to facebook and check if he is already exist in my database? if not so i get his information(by using facebook API) and add the user in my data base and each time he visits the application i update his information.
With respect to his friends i get all facebook ids of the user friends and then loop these IDs and get the pic of each ID.
Download Facebook Developer Toolkit that enables u communicate with facebook and use facebook API to get user information.
hope that is will help u
Visit my application in facebook and u will see these features at the following link :
http://apps.facebook.com/hanggame/
Getting the session Key :
protected void Page_Load(object sender, EventArgs e)
{
//Facebook code for integration with facebook users:
_fbService.ApplicationKey = "Application Key";
_fbService.Secret = "Secret Key";
_fbService.IsDesktopApplication = false;
string sessionKey = (string)Session["Facebook_session_key"];
if (Session["Facebook_userId"] != null)
userId = (long)Session["Facebook_userId"];
// When the user uses the Facebook login page, the redirect back here will will have the auth_token in the query params
string authToken = Request.QueryString["auth_token"];
if (!String.IsNullOrEmpty(sessionKey))
{
_fbService.SessionKey = sessionKey;
_fbService.uid = userId;
}
else if (!String.IsNullOrEmpty(authToken))
{
_fbService.CreateSession(authToken);
Session["Facebook_session_key"] = _fbService.SessionKey;
Session["Facebook_userId"] = _fbService.uid;
Session["Facebook_session_expires"] = _fbService.SessionExpires;
}
else
{
Response.Redirect(#"http://www.Facebook.com/login.php?api_key=" + _fbService.ApplicationKey + #"&v=1.0");
}
userId = _fbService.uid;
//End of Facebook code
}