Cannot Facebook "Like" with Graph API's /OBJECT_ID/likes - android

I'd like to implement a like button in my Android app. The Graph API doc sais publishing likes can be done with /OBJECT_ID/likes.
/OBJECT_ID/likes
Like the given object (if it has a
/likes connection)
However if i implement this:
Bundle par = new Bundle();
par.putString("access_token", ACCESS_TOKEN);
facebook.request(APP_ID + "/likes", par, "POST");
it just does nothing but returns an empty (data content) JSON array. (publish_stream permission is given.)
APP_ID is my app's FB id, and i guess it'd be the OBJECT_ID so i don't understand.
How can i implement then a Like button?

You cannot force users to like your application or your fan page (due to spamming reasons). The only way you can get them to like your page/app is embedding the like fbml code or iframe in a web view. That documentation is in place to like a friends wall post or comment or photo, as those are the types of items you can like for a user, in case for example you were writing a Facebook client. If that is what you are trying to do, don't send the app_id as you are doing, but send the post id of the users post.

Related

How to get dailymotion videos list

I want to get list of videos from daily motion, i have registered in daily motion. it's retrieved API key and secret key but i have no idea what is the next step, i want to show the list of videos and show the detail.
I have referred https://developer.dailymotion.com/api but i could not find any way how to integrate in my application.
Please guys help to solve this!!!
In case you want to get videos only (no channel or playlist) You can simply do:
https://api.dailymotion.com/videos?page=2
Response will be paginated so you need to add page numbers
https://api.dailymotion.com/videos?page=2
You can also get more >10 results
https://api.dailymotion.com/videos?limit=100
I would recommend you to make a GET request using https://github.com/amitshekhariitbhu/Fast-Android-Networking this library and sending the API key in your request header. This is one of the best networking libraries and very easy to implement. Use .addHeaders("token", "1234") to add API key in your request.
Set up Retrofit and Moshi/Gson (Best Guide: https://guides.codepath.com/android/Consuming-APIs-with-Retrofit) and then it would be just calling an endpoint.
#GET("https://api.dailymotion.com/channel/music/videos")
Call<List<Video>> getVideos();
or
#GET("https://api.dailymotion.com/user/{userId}")
Call<List<Video>> getVideos(#Path("userId") String userId);
And to use the Access Token:
#GET("https://api.dailymotion.com/videos?")
Call<List<Video>> getVideos(#Path("userId") String userId, #Query("sort") String sort);

How to interact with web-page in background

Is there any way, through which my android application can interact with a web page that I provide?
For example: I want to retrieve user information from a web based erp-system. So first user needs to log-in with his/her credentials. After that, the student home page opens up. I want to know, suppose that I have the credentials in simple text.
How can I insert, 'click' certain buttons elements of the web-page, in background, without any user intervention. Also, once the homepage loads up, Is there any way through which I can access data from DOM elements?
Simply, I just want to know, is this even possible? All the user interaction taking place in the background? And if yes, can someone just point me in a right direction? I actually don't know how to 'term' this process.
Thank You.
EDIT:
I found out, that the button has an associative function 'logincheck()'. So, by calling this function, same can be achieved, right? Problem is, how the credentials can be inserted in the labels and how this function can be called?
You can manually download the html page on interests and parse it using regex to find out info contained in DOM elements.
Or it s possible to automatize also the login by using for example Python and the request lib to issue HTTP requests and retrieve the pages.
Another option, more graphic oriented is to use JWebUnit lib (for Java) to navigate the pages and login etc
If you are the owner of the webpage or if you have access to it's code, look for division IDs for the form fields that you're trying to fill. Then, in your WebView, once the login page loads, you can fill the form using JavaScript -
Assuming that the username form field has an id 'username' and the password field has an id 'password',
webView.getSettings().setJavaScriptEnabled(true);
String js = "javascript:" +
"document.getElementById('username').value=" + "'" + username + "';" +
"document.getElementById('password').value=" + "'" + password + "';" +
"document.forms[0].submit();";
webView.loadUrl(js);

Exact Twitter search in Android

I have implemented a Twitter search in my android app, when I search for a string I get all tweets associated, but I only want one result showing only the string I'm looking for, not the entire tweets.
For example, if I'm looking for "MTVAwards" I get something like "Hi #MTVAwards, regards from Michigan"... The result I want is "MTVAwards" if exists, if not a button to create it.
I´m only looking for hashtags (#)
Thanks

Why I am getting zero values for Facebook page status read?

I am facing problem in getting Facebook data
I am using Facebook SDK for page status read, for this I am using the following URL :
https://graph.facebook.com/gennextapps/statuses?limit=50&access_token=" + access_token
At first I am getting values, but, after two times I am unable to get the values.
Is there any difference between statuses and feed in URL?
The statuses and feed are two different things. "Statuses" are only the items posted by the page, while "feed" includes items posted by others.
I found this page documentation
Statuses: An array of Status message objects. The Page's status updates.
Feed: An Array of Post objects containing (up to) the last 25 posts. The page's wall.

Facebook Graph API Groups

I try get information about own groups over Graph API.
On me/groups I get list of groups. But I not understood what is params: bookmark_order.
Also we can see param unread:1. If I right, it present if another user set some change in group (post new comment). If I refresh group page in browser or open in native android app, then unread is no longer appears. After which api request I can remove unread flag?
Also at group's wall I can ask question. But {group_id}/feed not contain this posts. How I can get it?
I have group document. I can get data about this document: subject, message. But if in document I insert image, then in message param I has string about this image: (img:301666969868743). How can I get this image? Simple GET-request with 301666969868743 (I assumed that this long decimal is ID) return false.
bookmark_order (see https://developers.facebook.com/docs/reference/api/user/)
An array of objects containing the version(old-0 or new Group-1),
name, id, administrator (if user is the administrator of the Group)
and bookmark_order(at what place in the list of group bookmarks on the
homepage, the group shows up for the user).
unread
Doesn't appear to be documented. I would presume this would be a read-only value that facebook controls.
Log a documentation bug with facebook and ask them to explain it. (https://developers.facebook.com/bugs?search_view=search&search_ids%5B0%5D=208685622513742)
question not appearing in {group_id}/feed
Tested it and you're right, it doesn't appear. Good find. You should log this as a bug with facebook.
(https://developers.facebook.com/bugs)
Group document with image
When I did an image in a document, I too got the cryptic (img:###) inside the message of the returned object from {group_id}/docs. However I was able to find it on the graph using https://graph.facebook.com/####?access_token=#### and it returned the results. So I'm not sure how to help you with this one

Categories

Resources