PHP nasıl bir API oluşturabilirsiniz

1 Cevap php

Merhaba Facebook ya da diğer siteler gibi benim sosyal ağ şey üzerinde temel bir API ve uygulama / apps sistemi oluşturmak için arıyorum, sitemde php / mysql olduğunu var. İşte bazı sorular vardır.

1)
Basically what I want to do is give a user a API key and secret. After I have these how can I use them in my php app to authenticate a user request which would come from there server?

2) I can basically build an API to send a request to my server with CURL and get the result back to the page in XML or JSON or whatever, the problem is when sending the request the user would have to know the user ID they want to send to lookup data against, this is fine for an API but I am wanting to have an Apps section where the user's app site would be using the API and would be loaded into my site in the app section with an iframe, the problem is, I need to find a good way to make it where a logged in user on my site can go to the app section and go to an app and there username should be available to that page loaded in the iframe. Facebook and myspace do this somehow and many other sites; I am lost how to get around this hurdle.

Bu herhangi Herhangi bir Yardım gerçekten takdir, teşekkür ederim


Update:
I just had an idea, if I require a cookie to be set when a user visit's my site, then they would have a cookie and it could hold there User ID, then my API script could look for that cookie to exist and grab it's value?

1 Cevap

IFRAME kullanarak size uçak, o zaman, API ayrı bir web sitesi (IFRAME içinde web sitesi) üzerinde barındırılan eğer çerez kapmak mümkün olmaz. Çerez bunun için kuruldu web sitesinde görülebilir.

Ben sadece FBML (değil IFRAME,) ile Facebook API kullanmış ama tüm yaptıkları temelde "etiketi" aradığını bilgi ile sayfa içinde ne onların yerini almaktadır. Ben daha iyi bir yolu olup olmadığından emin değilim, ama muhtemelen app sunucudan bir sayfa diyebiliriz (diyelim app http://example.com/app/ barındırılmaktadır ve http://example.com/app/?id=28318&name=John%20Maguire adlandırılır) ve API kod işlemek ve bir değişkene çevirmek var?

Belki Facebook API istemci kaynak koduna bakmak gerekir.