簡體   English   中英

如何在 C# 桌面應用程序中使用 PHP 代碼

[英]How I can use a PHP code in C# desktop application

Is there any way to run the PHP code on the c# app since I'm working on an application that requires to implement of this site's API but there is no documentation except for PHP, so is there any way I can use this piece of code在 c# 應用程序中,如果可能的話,在 C# 中轉換此代碼。

public $api_url = 'https://smm-bomb.com/api/v2'; // API URL

public $api_key = ''; // Your API key

public function order($data) { // add order
    $post = array_merge(array('key' => $this->api_key, 'action' => 'add'), $data);
    return json_decode($this->connect($post));
}

一種選擇是使用 C# 重寫調用,如果需要,請查看文檔。
另一種方法是制作包含初始調用的自定義php-api
然后從 C# 只需使用您的php-api
Postman可以成為檢查您的自定義php-api以及C# code generation的有用工具


---自定義php-api---

<?php
$out = [];
//mainly here will be the return of api-call
$out["mykey"]="myvalue";
echo json_encode($out);
?>
//sample output
//{"mykey":"myvalue"}

這段代碼應該可以通過鏈接訪問,例如: https://yoursite/custom-api (出於安全目的,可以在查詢字符串上使用令牌/custom-api?key=123mykey ->trivial approach)

使用PostMan查看代碼生成

C#

See, use C# directly and use the html-php method, like php embedded into html code and then link with a webbrowser proc in background and make it work: ,) Also don't do that, use direct C# and dont but any embed錯誤!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM