Api发帖请求。我的脚本出了什么问题?

时间:2017-05-11 14:38:29

标签: arrays json api

我正在尝试为能源公司创建一个帖子请求,但我一直收到一条失败的消息。你们可以帮助我,如果这看起来让我知道吗?谢谢

 $fields = array("firstName"=>"Test",
"lastName"=>"Tester",
"dob"=>"01/01/1980",
"socialSecurity"=>"123456789",
"phoneAreaCode"=>"111",
"phoneExchange"=>"111",
"phoneLine"=>"1111",
"email"=>"test@test.com",
"serviceAddress"=>array(
"line1"=>"123 Main ST",
"line2"=>"Unit 123",
"city"=>"Decatur",
"state"=>"GA",
"zip"=>"30031"
),
"mailingAddress"=>array(
"line1"=>"7001 SW 24th AVE",
"city"=>"Gainesville",
"state"=>"FL",
"zip"=>"32607"
),
"utilityName"=>"AGLC",
"ratePlanName"=>"6 mo Fixed",
"requestedService"=>"SWITCH",
"language"=>"ENGLISH",
"referredBy"=>"Test Referral",
"marketerName"=>"Test Marketer");

$str_data = json_encode($fields);
$uri = "https://sandbox.infiniteenergy.com/api/enrollments";

$response = \Httpful\Request::post($uri)
->addHeaders(array(
'Content-Type' => 'application/json', 
'Accept' => 'application/json',
'AccessKeyId' => 'a13bd2fa-f959-4f91-b238-9757a3172945'
))
->body($str_data)
->sendsJson()
->send();

我不断获得{“成功”:false,“message”:“Method not allowed”,“data”:null}

我准备把头发拉出来今天需要修好。

0 个答案:

没有答案