Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Tom S. Posted March 20, 2019 Posted March 20, 2019 I'm trying to make an external request using \IPS\Http\Url::external($somepath)->request()->setHeaders( array('Content-Type' => 'application/json') )->post( array()); So I can set the body and the headers. But How do I set the authorization? So either CURLOPT_USERPWD or a token?
Adriano Faria Posted March 20, 2019 Posted March 20, 2019 I use in a resource: $result = \IPS\Http\Url::external( "api.openweathermap.org/data/2.5/weather?q=Brasilia,br?&lang=pt&units=metric&appid=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" )->request( 20 )->get(); $data = json_decode( $result );
Ryan Ashbrook Posted March 20, 2019 Posted March 20, 2019 $response = \IPS\Http\Url::external( "url" ) ->request() ->setHeaders( array( 'Content-type' => 'application/json' ) ) ->login( 'username', 'password' ) ->post( array() ) ->decodeJson(); $response = \IPS\Http\Url::external( "url" ) ->request() ->setHeaders( array( 'Authorization' => "Bearer {$this->token['access_token']}", 'Content-type' => 'application/json' ) ) ->post( array() ) ->decodeJson(); I would really suggest going over our developer documentation - it's all covered there. 🙂
Recommended Posts
Archived
This topic is now archived and is closed to further replies.