好的,所以我对整个mulesoft事情都很陌生。我目前正在做的是我有一个mulesoft流程,首先授权我到Linkedin然后获取我的基本个人资料详细信息。我知道要做的是在我的React模型中显示该信息,如何从我的mulesoft流中获取json结果进入我的React应用程序并显示它?
这是我的mulesoft流程
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
xmlns:tcp="http://www.mulesoft.org/schema/mule/tcp" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:oauth2="http://www.mulesoft.org/schema/mule/oauth2" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:linkedin="http://www.mulesoft.org/schema/mule/linkedin" xmlns:barn1="http://www.mulesoft.org/schema/mule/barn1" xmlns:barn="http://www.mulesoft.org/schema/mule/barn" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/linkedin http://www.mulesoft.org/schema/mule/linkedin/current/mule-linkedin.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/oauth2 http://www.mulesoft.org/schema/mule/oauth2/current/mule-oauth2.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/tcp http://www.mulesoft.org/schema/mule/tcp/current/mule-tcp.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="3000" doc:name="HTTP Listener Configuration" connectionIdleTimeout="3000000"/>
<http:request-config name="AcceptHTTP_Request_Configuration" host="api.linkedin.com/v1/people/~?" port="403" doc:name="HTTP Request Configuration" connectionIdleTimeout="300000000" protocol="HTTPS">
<oauth2:authorization-code-grant-type clientId="77ii50ttcezoti" clientSecret="aifsEkcXEiMsayru" redirectionUrl="http://localhost:3000/callback">
<oauth2:authorization-request authorizationUrl="https://www.linkedin.com/oauth/v2/authorization?response_type=code&state=987654321" localAuthorizationUrl="http://localhost:3000/authorize"/>
<oauth2:token-request tokenUrl="http://linkedin.com/oauth/v2/accessToken" >
<oauth2:token-response >
<oauth2:custom-parameter-extractor paramName="token_1" value="#[json:token_type]"/>
</oauth2:token-response>
</oauth2:token-request>
</oauth2:authorization-code-grant-type>
</http:request-config>
<http:request-config name="HTTP_Request_Configuration" host="api.linkedin.com" port="8081" doc:name="HTTP Request Configuration"/>
<oauth2:token-manager-config name="Token_Manager_Config" doc:name="Token Manager Config"/>
<flow name="testingFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/linkedin" doc:name="authorize" allowedMethods="GET"/>
<http:request config-ref="AcceptHTTP_Request_Configuration" path="/" method="GET" doc:name="getaccesstoken"/>
<json:xml-to-json-transformer doc:name="XML to JSON"/>
</flow>
</mule>
答案 0 :(得分:1)
根据我的理解,您已获得linkedin个人资料信息。 现在在mule中,信息将作为有效载荷提供,您可以通过#[payload]访问它,并将作为响应提供。要在任何前端技术(反应,角度,主干)中访问它,只需调用相应的骡子流。
在您的情况下:localhost:3000 / linkedin(调用GET)
答案 1 :(得分:0)
您需要将配置文件信息作为Mule API的有效载荷返回,之后您需要与邮递员一起测试您的API
如果每个想法都运行良好,则需要使用前端技术(React,Angular,VueJs ...)创建相同的请求