Publish an action without an external recipe webpage? - facebook-javascript-sdk

I'm working on a project where we try not to use any server side languages.
Is it possible to publish an action without an external recipe webpage?
I see an example on http://developers.facebook.com/docs/technical-guides/opengraph/publish-action/
FB.api('/me/recipebox:cook', 'post', { recipe :
'http://www.example.com/pumpkinpie.html' });
but it requires a recipe from an external page.

You can publish the actions without server side languages. But what do you mean by the external page?
You just required to add the meta tags in the page where you are publishing the actions.

You can try using the new object API, the objects will be hosted at Facebook.
See https://developers.facebook.com/docs/opengraph/using-object-api/

Related

Bypass setup wizard in fusion auth to create application

I am using Fusion Auth as an auth backend for my project.
After starting up the container as shown here(https://fusionauth.io/docs/v1/tech/installation-guide/docker), if we open the URL(Ex: http://localhost:9011) we need to create an admin user and then we will be able to create Application, API Key, Lambda.
As my project doesn't involve UI interaction, I wanted to create Application without involving UI interaction(i.e., setup-wizard).
I was unable to find an API that relates to setup-wizard.
As I saw Since this is your own private instance of FusionAuth, you need to create a new administrator account that you will use to log in to the FusionAuth web interface. in setup-wizard I thought this is required only for UI, So I tried to create Application using this(https://fusionauth.io/docs/v1/tech/apis/applications#create-an-application) API, but it is returning a 401(Unauthorized).
Can someone help me to either create an application without authentication or bypass setup-wizard?
The FusionAuth Kickstart does exactly what you need. It will allow you to pre-define the configuration that you require in a JSON file and then the system will bootstrap itself automatically.
The base use case it to provision an API key which would allow you to programmatically configure the rest of the system by using APIs after an API key has been created.
{
"apiKeys": [{
"key": "a super secret API key that nobody knows"
}]
}
You also have the option of building your entire configuration in the Kickstart definition. There are a bunch of examples and walk throughs on the Kickstart installation guide.
Good luck!

Tag missing from API Gateway when using tags in serverless

I put tag information in tags in provider of serverless.yml. After executing sls deploy, I checked lambda from console of AWS, tag setting was done. However, when we confirmed the apigateway from AWS' console, the tag information was empty.
How can I tag information to the API gateway resource?
Tags for API Gateway arrived after serverless' core functionality was developed.
There is an open issue on Github discussing the inclusion of this functionality.
Right now you'll have to use the serverless-tag-api-gateway plugin to manually add tags to these resources.

Why create a separate application for RESTful API?

In the guide for Yii 2 it is said:
While not required, it is recommended that you develop your RESTful
APIs as a separate application, different from your Web front end and
back end for easier maintenance.
Source: RESTful Web Services - Quick Start
What does this mean? Would this be a completely different application or can it be in the same folder as the 'normal' web application? I've just started with my application so I can change things easily, more or less. But I'm wondering: if I would create another application than my business logic would not be accessible.
Why and how I should create another application? And when it's not required?
It means you have to create an application like frontend or backend(Yii 2 advanced application template),
what you have to do is create another directory call 'api' same as backend or frontend, and it'll contain folder structure same as backend|frontend except assets, views, widgets etc.
Basically you need folder structure like this
api
-config
-modules
--v1
---controllers
---models
-runtime
-tests
-web
backend
common
console
environments
frontend
If you'r going to use Yii 2 basic application template to develop rest api, it's posible. create module call 'api' and create a sub directory call 'v1' as sub-module.
(Yii doc -A module may consist of sub-modules.)(GiovanniDerks - backend sub-modules)
-modules
--api
---v1
----controllers
----models
There is an advantage of using one of these folder structure, because you don't have to worry about route much.
https://domain.com/api/v1/products
Here is good example for RESTful API with advance template
Setup RESTful API in Yii2(budiirawan)
API & RESTFull API are different. RESTFull APIs have to have REST standards. basically that's why APIs are developed as separate application. in normal app, we create 4 actions for CRUD functions. but in yii2 RESTFull API we just create One action for all CRUD functions. (Controllers extend from REST Active Controller - yii\rest\ActiveController ). in core code you can find find 4 actions for different headers GET,POST,PUT & DELETE .
'index' => ['GET', 'HEAD'],
'view' => ['GET', 'HEAD'],
'create' => ['POST'],
'update' => ['PUT', 'PATCH'],
'delete' => ['DELETE'],
for authentication basically we can use 'HTTP Basic Authentication'
This article explain the idea and the why , also it provide you a starter project called "yii2-advanced-api": http://budiirawan.com/setup-restful-api-yii2/
IMHO if you need REST API for Angular.js or Knockout.js AJAX calls on your website it's an overhead to do it as a separate application. Because you will have issues with cross-domain AJAX calls (especially for POST requests).
I think it's enough to make a module (API) in the frontend for REST API

YouTrack workflow - HTTP request

is it possible to perform a HTTP request in YouTrack workflow?
I would like to create a workflow that calls some REST API whenever user logs some time on an issue.
YouTrack workflow rules run inside a pretty restricted sandbox. Currently, there're no means to do what you want.
YouTrack Workflows are providing some methods to communicate with foreign servers:
https://www.jetbrains.com/help/youtrack/standalone/2017.1/Workflow-REST-API.html
A simple example (taken from the link above):
// post new issue content to third-party tool and add response as a comment
when issue.becomesReported() {
addHttpHeader("Content-Type", "text/html");
var response = doHttpPost("http://server.com/issueRegistry", issue.description);
issue.addComment(response)
}
I've never worked with timetracking inside YouTrack, so no concrete example is here. But on page linked above, there is a section with "Custom Time Tracking with the Harvest Web Service", maybe you can adapt some code from there.

Problems working with Google Calendar Api V3 and PHP

I'm just trying to make a little, simple application (that i already made two years ago in Objective-C with api V1) that presents a screen with time of event and description and a button : "insert event in your calendar".
Every user has, obviously, to configure the application with his google username and password.
The app simplifies some process using the first calendar available.
I had infinite problem trying to do it with javascript (this app will be made in html5), so, looking at docs, I ended up trying to make a back-end on my server in php5 (thought it could be easier...ohohoho).
So, i read docs from here : https://developers.google.com/google-apps/calendar/
What i did :
1)
Get to the Google Developers Console.
Created a project.
I now have this (not real keys):
OAuth 2.0
Client ID 352xxxyy9.apps.googleusercontent.com
Email address 3527xxxy#developer.gserviceaccount.com
Service Account
Client ID 3523xxxyy419-vpfgdfg9u77s0.apps.googleusercontent.com
Email address 35ssss9-zzzzsnhavna78ea0b9gvn6a9u77s0#developer.gserviceaccount.com
Public key fingerprints :ac15ddfxdffrtg5565fgfg545r
2)
I installed Google APIs Client Library for PHP (beta) in my server.
doc says:
Using the Google APIs Client Library for PHP requires that you download the PHP source. In the future, packages will be provided. Refer to the project page for more details.
Run the following commands to download and install the source: svn blaj blah blah.
I copied the entire source in my server. Easy :)
Then..
3) You can now import the classes you will need using the following statements:
require_once "../src/apiClient.php";
require_once "../src/contrib/apiCalendarService.php";
Ok, i'll insert them in my php script !
4)" Configure your app"
You must instantiate a client to make requests to the API. All requests to the Google Calendar API require authorization.
The following code demonstrates how to configure an authorized service object using OAuth 2.0 for native applications. For more information, see Authorize Requests.
To find your project's client ID and client secret, do the following:
Go to the Google Developers Console.
Select a project.
In the sidebar on the left, select APIs & auth. In the displayed list of APIs, make sure the Google Calendar API status is set to ON.
In the sidebar on the left, select Credentials.
Find the lines labeled Client ID and Client secret. Note that there may be a client ID without a client secret, for use with Compute Engine and App Engine; in that case, create a new client ID and client secret by selecting Create New Client ID.
Edit the src/config.php file to put in your developer API information.
global $apiConfig;
$apiConfig = array(
// Site name to show in Google's OAuth authentication screen
'site_name' => 'www.example.org',
// OAuth2 Setting, you can get these keys in Google Developers Console
'oauth2_client_id' => 'YOUR_CLIENT_ID',
'oauth2_client_secret' => 'YOUR_CLIENT_SECRET',
'oauth2_redirect_uri' => 'YOUR_REDIRECT_URL',
// The developer key; you get this from Google Developers Console
'developer_key' => 'YOUR_DEVELOPER_KEY',
...
// Which Authentication, Storage and HTTP IO classes to use.
'authClass' => 'apiOAuth2',
....
// Definition of service specific values like scopes, OAuth token URLs, etc
'services' => array(
'calendar' => array('scope' => 'https://www.googleapis.com/auth/calendar'),
)
);
But they are DIFFERENT from the key i have, what's wrong ????
What are client secrets ? redirect_url??
Please help.
I think you need to setup a service account access as described here:
https://code.google.com/p/google-api-php-client/wiki/OAuth2#Service_Accounts
I had difficulties to get it work as I made many trial and errors and my cache got filled with non-working token.
If ever you find yourself not able to access the calendar even after following all the steps, try to change this line of code:
$client->setAssertionCredentials(new Google_AssertionCredentials(SERVICE_ACCOUNT_NAME, array('https://www.googleapis.com/auth/prediction'),$key));
to this:
$client->setAssertionCredentials(new Google_AssertionCredentials(SERVICE_ACCOUNT_NAME, array('https://www.googleapis.com/auth/prediction'),$key, 'notasecret','http://oauth.net/grant_type/jwt/1.0/bearer',false,false));
The last false tells AssertionCredential class to not use any cache. I did it once and then it worked with it set to true afterward.
First go here https://console.developers.google.com/project that is where you configure your app...
Click on your project, then on the left side you will see APIs & Auth, click on Credentials. You will need to create your OAuth, and Public API Access keys.
Once you have done that you will then enter those into the appropriate client_id, secret, redirect etc.
The redirect uri is the same page your app is on, its the page the user gets sent back to after authorizing.
I had the same problem.
On this page, when you click on the Create new Client Id, choose Web application and it shoudl give you the client secret key as well.
https://console.developers.google.com/project
Add a project etc.
Hope it helps