RpcRequestItem, but PHP doesn't seem to // complain. $options = MakeRequestOptions::fromRpcRequestItem($requestItem); $makeRequestClass = Config::get('makerequest_class'); $makeRequest = new $makeRequestClass(); $contextClass = Config::get('gadget_context_class'); $context = new $contextClass('GADGET'); $response = $makeRequest->fetch($context, $options); // try to decode json object here since in order // to not break gadgets.io.makeRequest functionality // $response->getResponseContent() has to return a string $content = json_decode($response->getResponseContent(), true); $result = array( 'content' => $content ? $content : $response->getResponseContent(), 'status' => $response->getHttpCode(), 'headers' => $response->getResponseHeaders() ); } catch (SocialSpiException $e) { $result = new ResponseItem($e->getCode(), $e->getMessage()); } catch (\Exception $e) { $result = new ResponseItem(ResponseError::$INTERNAL_ERROR, "Internal error: " . $e->getMessage()); } return $result; } /** * Only RPC operations supported. * @param RequestItem $request The request item. */ public function handleDelete(RequestItem $request) { throw new SocialSpiException("DELETE not allowed for http service", ResponseError::$BAD_REQUEST); } /** * Only RPC operations supported. * @param RequestItem $request The request item. */ public function handlePut(RequestItem $request) { throw new SocialSpiException("PUT not allowed for http service", ResponseError::$BAD_REQUEST); } /** * Only RPC operations supported. * @param RequestItem $request The request item. */ public function handlePost(RequestItem $request) { throw new SocialSpiException("POST not allowed for http service", ResponseError::$BAD_REQUEST); } /** * Only RPC operations supported. * @param RequestItem $request The request item. */ public function handleGet(RequestItem $request) { throw new SocialSpiException("GET not allowed for http service", ResponseError::$BAD_REQUEST); } }