0

我正在尝试从 PHP 访问 SocialCast 的 API。他们只有一个例子,用 curl 完成:

# Curl Example
curl -X POST -d 'password=demo&email=emily@socialcast.com' -v https://demo.socialcast.com/api/authentication.xml

如何使用 PHP 进行登录?

这是 API 文档:http: //developers.socialcast.com/api-documentation/http-basic-authentication/#authentication_api_create

4

1 回答 1

1

您可能想使用 php curl 包装器http://php.net/manual/en/book.curl.php

像这样的东西:

 $ch = curl_init("https://demo.socialcast.com/api/authentication.xml");
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, "password=demo&email=emily@socialcast.com");
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION , 1);
 curl_setopt($ch, CURLOPT_HEADER , 0);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
 $resp = curl_exec($ch);
于 2012-08-15T14:17:05.960 回答