Check whether facebook user likes my app - vb.net

I've read several sources now but did not find a solution: I'm using Facebook C# SDK with ASP.net 4 and VB.net 2010. I have a Facebook Canvas application. I'm using Canvas Auth.Authorize and it works fine. Now I want to know whether the currently logged in user already likes my app. How could I do that?
'SignedRequest' does not seem to work because according to Facebook Documentation "This field is only present if your app is being loaded within a Page Tab".
graph/user/likes is also not an option because I don't want to ask the user to grant access for my app to all his likes.
But the Facebook Plugin is able to differ whether the current user likes my app or not, so I'm quite optimistic that there is a way which I just did not find yet.
Many thanks!

You can use the graph API to call the users likes. Instead of requesting all of the likes simply request the single one you want.
https://graph.facebook.com/userId/likes/appId
If you the user has liked the page the result will return details about the page. For example:
{
"data": [
{
"name": "Microsoft Office Web Apps",
"category": "Software",
"id": "121883824529155",
"created_time": "2012-03-14T06:48:47+0000"
}
],
"paging": {
"next": "https://graph.facebook.com/me/likes/121883824529155?format=json&limit=5000&offset=5000&__after_id=121883824529155"
}
}
If the user has not liked the page you will receive empty data.
{
"data": [
]
}
With the Facebook C# SDK you would make this request as follows:
var client = FacebookClient("access_token_here");
dynamic result = client.Get('/me/appId');
if (result.data.Length == 1) {
// User has liked page
}

Related

Copy JSON file and load from user database

Im working on a project that will be used in a closed environment for events within a school.
The basic idea is to have a JSON file with a bunch of different objects that users who will login through a website will be able to "collect"
{
"Object Type": {
"Ball": {
"Red": {
"Collected": false
},
"Blue": {
"Collected": false
},
"Yellow": {
"Collected" : false"
}
}
}
}
The problem im running into is how to store this JSON file "unique" for each user.
If a user logs in they should be able to edit their collection and when they logout it's saved. Each user should have a unique collection that has the same "base template".
Both the amount of objects and users will be upwards in the hundreds.
Im writting the website itself in ASP.NET but cant seem to find any good solutions how to tackle this problem.
The user login will be stored in a SQL server.
Anyone who got experience with similar problems who managed to find a solution? Or would it just be better to change language and datastorage structure.

How do I use an ACS Token?

I am building a react-native app that utilizes the Google Books API. The API provides a property known as "ACSTokenLink" which downloads an .acsm file, not an .epub. A simple Google Search tells me that this .acsm file is for content protection and can only be opened with Adobe Digital Editions.
Google completely dropped the ball, failing to mention any of this in their API contract:
https://developers.google.com/books/docs/v1/using
Google API forums are a ghost-town, so I'm asking here in an attempt to learn more about these files and their use.
So, if I am developing a react-native e-reader, am I completely barred from using such a file?
Looking at the accessInfo slice sample from Google Books API :
The accessInfo section is of particular interest in determining what features are available for an eBook.
"accessInfo": {
"country": "US",
"viewability": "PARTIAL",
"embeddable": true,
"publicDomain": false,
"textToSpeechPermission": "ALLOWED_FOR_ACCESSIBILITY",
"epub": {
"isAvailable": true,
"acsTokenLink": "https://books.google.com/books/download/The_Google_story-sample-epub.acsm?id=zyTCAlFPjgYC&format=epub&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api"
},
"pdf": {
"isAvailable": false
},
"accessViewStatus": "SAMPLE"
}
The epub section will have an isAvailable property indicating if this type of ebook is available.
We can use acsTokenLink as the "download epub link" and can set up our conditional:
if( book.accessInfo.epub.isAvailable ) {
axios.get(acsTokenLink).then( responseData => /* store epub in app storage here */ )
}
Looking further: I have found Epub.js as one solution to display epub files with React Native. Additionally, here's an example repo.

Add Product Images with Shopify API

We have a bunch of disassociated product images in our Shopify store that support could not re-associate. I set up a Postman collection runner to update all these missing images, and it seems to be working in our test environment....
Except, the API call is replacing the default product image with a new image rather than adding the image. I'm using a standard PUT request to the API using the example in their API docs:
PUT /admin/api/2019-04/products/#{product_id}.json
{
"product": {
"id": 632910392,
"images": [
{
"src": "http://example.com/rails_logo.gif"
}
]
}
}
I get that it's an array I'm sending in, so I'm thinking it's overwriting the array each time rather than adding a new element. I tried using a single element variable of "image" in the JSON but that didn't work.
Any ideas?
If you want to add the image use ProductImage resource instead of Product resource.
Product Image Documentation
POST /admin/api/2019-04/products/#{product_id}/images.json
{
"image": {
"src": "http://example.com/rails_logo.gif"
}
}

Universal Links iOS 9 - Issue

I have implemented Universal links in iOS app. It works perfectly when I put the url in external app such as "Notes" and then tap it. It opens the app.
What I want to achieve is that when someone visits a specific url of my webpage, the ios app should be launched by itself. So in order to accomplish this, I have put:
applinks:www.mydomain.com
in my entitlements.
And the following in my "apple-app-site-association" file
{
"applinks":
{
"apps": [ ],
"details":
[
{
"appID": "team_id.com.teamname.app_name",
"paths": ["/path-CompA/path-CompB/"]
}
]
}
}
But When I navigate through my website, and I reach the path mentioned in json file, it only shows the bar at top of web page saying "Open in App_name" with "Open" button on right side.
I want to know if its the default behaviour of Universal links to not open the app if user is coming from the same domain? If its not the case then how does it open the app form "Notes".
Please note that my json file is not signed but I have put it on my website which is on https.
Thanks,
A couple of things. Can you try changing your apple-app-site-association file code as such?
{
"applinks": {
"apps": [],
"details": [
{
"appID": "team_id.com.teamname.app_name",
"paths": [
"*",
"/"
]
}
]
}
}
You can check your format with this validation tool: https://search.developer.apple.com/appsearch-validation-tool/
The answer is that basically, this behavior is expected as of iOS9.2, with Universal links. Universal links only work from a different domain.
With Branch (https://branch.io/), you can use one domain for links (bnc.lt), so that when you (as a developer using branch) host universal links on your site, they still operate as expected.
Also, for universal links from other domains (not to the same domain), you can 'unbreak' the safari redirect behavior by long-pressing on the link from an application and choosing 'Open in «App»'. I hope this helps!

How can i use the port.postmessage to send info from the background page to the content script in a Google Chrome extension

I've been able to send data from the background page to the content script. but this is done using sendrequest(). I will need to send data back and forth so I'm trying to figure out the correct syntax for using the port.postmessage from background page to content script. I have already read, several times, the google page on Messaging and I don't seem to get it. I even copied the code directly from the page and tested with no result. All I'm trying to do for now is send data from background page to content script using connect as opposed to sendrequest. The response from the content script I will deal with later as code with this response has been the main thorn. I just want to understand the process one step at a time without the extra knowledge of sending a response back.
I'm not sure if this contravenes the rules of this board but can someone PLEASE give me an example of some code to do this (background page and content script excerpt, the background page is the sender).
I've asked for assistance several times on this site only to be told to read the documentation or check out sites I've already visited.
If you just want any example of opening a port from the extension to a content script, here's the simplest I can think of. The background just opens a port and sends "Hello tab!" over the port, and the content script sends a message to the background any time you click on the webpage.
I think this is pretty simple, so I don't know why you are so stressed. Just make sure that the content tab is already listening when the background tries to connect (I do this by waiting until the "complete" event).
manifest.json:
{
"name": "TestExt",
"version": "0.1",
"background_page": "background.html",
"content_scripts": [{
"matches": ["http://localhost/*"], // same as background.html regexp
"js": ["injected.js"]
}],
"permissions": [
"tabs" // ability to inject js and listen to onUpdated
]
}
background.html:
<script>
var interestingTabs = {};
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
// same as manifest.json wildcard
if (changeInfo.url && /http:\/\/localhost(:\d+)?\/(.|$)/.test(changeInfo.url)) {
interestingTabs[tabId] = true;
}
if (changeInfo.status === 'complete' && interestingTabs[tabId]) {
delete interestingTabs[tabId];
console.log('Trying to connect to tab ' + tabId);
var port = chrome.tabs.connect(tabId);
port.onMessage.addListener(function(m) {
console.log('received message from tab ' + tabId + ':');
console.log(m);
});
port.postMessage('Hello tab!');
}
});
</script>
injection.js:
chrome.extension.onConnect.addListener(function(port) {
console.log('Connected to content script!');
port.onMessage.addListener(function(m) {
console.log('Received message:');
console.log(m);
});
document.documentElement.addEventListener('click', function(e) {
port.postMessage('User clicked on a ' + e.target.tagName);
}, true);
});
Detailed documentation and easy (the most basic) examples shown in the documentation page.
Plus, a quick search in stackoverflow will allow you to see many similar questions with detailed answers.