后继 api php 卷曲

发布于 2024-12-27 00:40:23 字数 677 浏览 0 评论 0原文

任何人都会发现这有什么问题,它不起作用并且返回 null。

$request = array(
  "api_token" => $token,
  "name" => null,
  "byline" => "via api",
  "owner_id" => null,
  "id" => $id,
  "raw_theme" => $t,
  "friendly_name" => "Test"
);


$session = curl_init($url);
curl_setopt($session, CURLOPT_USERPWD, $user . ":" . $password);
curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $request);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
var_dump($response);

Anyone see anything wrong with this, it is not working and its returning null.

$request = array(
  "api_token" => $token,
  "name" => null,
  "byline" => "via api",
  "owner_id" => null,
  "id" => $id,
  "raw_theme" => $t,
  "friendly_name" => "Test"
);


$session = curl_init($url);
curl_setopt($session, CURLOPT_USERPWD, $user . ":" . $password);
curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $request);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
var_dump($response);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感情洁癖 2025-01-03 00:40:23

我不确定,但如果我尝试从 https://posterous.com/api 然后 post 参数的命名如下:

theme[byline]
theme[designer_url]
theme[friendly_name]
theme[raw_theme]
theme[thumb]

因此,也许您应该尝试将代码更改为类似以下内容:

$request = array(
  "api_token" => $token,
  "name" => null,
  "theme[byline]" => "via api",
  "owner_id" => null,
  "id" => $id,
  "theme[raw_theme]" => $t,
  "theme[friendly_name]" => "Test"
);

另外,我没有看到任何 owner_idnameid 参数。

I'm not sure but if I try to send a create new theme request from https://posterous.com/api then the post parameters are named like:

theme[byline]
theme[designer_url]
theme[friendly_name]
theme[raw_theme]
theme[thumb]

So, perhaps you should try changing your code into something like:

$request = array(
  "api_token" => $token,
  "name" => null,
  "theme[byline]" => "via api",
  "owner_id" => null,
  "id" => $id,
  "theme[raw_theme]" => $t,
  "theme[friendly_name]" => "Test"
);

Also, I don't see any owner_id, name or id parameters in their example.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文