通常、PHPのAPIへのPOSTはどうしますか?例えば外部API(vBulletin)にPOSTリクエストを行うにはどうすればよいですか?
:
login_login
Login a user and return a new session hash
Parameters
POST (Required)
vb_login_username - Username to login
Note that one of 3 vb_login_*password* methods is required.
vb_login_password - The password of the User. If client use this to login, the plain password may be sniffed during the pass in the network
vb_login_md5password - The md5 password of the User
vb_login_md5password_utf - The md5 password (Unicode) of the User
POST (Optional)
logintype - Possible value: 'cplogin' or empty. 'cplogin' means that the login will also allow the user to access the AdminCP if they have permission.
こちらをご覧ください:https://www.vbulletin.com/forum/content.php/365-User-Related-Methodsここ
より:https://www.vbulletin.com/forum/content.php/334-mobile-api
だから、APIスクリプトがhttp://somedomain.com/api.phpに配置されている場合、私はAPIへのPOSTを行うだろうか?
FORM ACTIONを外部APIページに設定すると、その外部サイトにユーザーが送信されるため、明らかに正しい方法にはなりません。
私はcURL POSTを行う必要がありますか?しかし、それは簡単なAPI呼び出しでは複雑に思えます。
APIは、通常、POST要求を別のより簡単な方法で理解していますか?
新しくログインしたユーザーのセッションハッシュを返すことが期待されます。しかし、AJAX/cURL /独自のクラスを作成することは、シンプルなPOST API呼び出しであると思われるものにとって非常に複雑に思えます。私はAPIの初心者なので多分複雑ですが、直感的には聞こえません。他のアイデア? – ProgrammerGirl
まあ、それはAPIに依存しますが、方法が必要です。 AjaxでもcURLでも難しいことはありません。 jQueryを使用するAjaxは可能な限りシンプルです(ほとんどのネイティブJavaScriptユーザーは私に同意しません)。 PHPを使ったcURLも非常にシンプルです。 – Eugene