我正在试验SammyK/LaravelFacebookSdk.试图从示例中运行此行:
$response = Facebook::get('/me?fields=id,name,email', 'user-access-token');
反过来运行 /var/www/vendor/facebook/php-sdk-v4/src/Facebook/HttpClients/FacebookGuzzleHttpClient.php line 61
public function send($url, $method, $body, array $headers, $timeOut)
{
$options = [
'headers' => $headers,
'body' => $body,
'timeout' => $timeOut,
'connect_timeout' => 10,
'verify' => __DIR__ . '/certs/DigiCertHighAssuranceEVRootCA.pem',
];
$request = $this->guzzleClient->createRequest($method, $url, $options);
try {
$rawResponse = $this->guzzleClient->send($request);
} catch (RequestException $e) {
$rawResponse = $e->getResponse();
if ($e->getPrevious() instanceof RingException || !$rawResponse instanceof ResponseInterface) {
throw new FacebookSDKException($e->getMessage(), $e->getCode());
}
}
$rawHeaders = $this->getHeadersAsString($rawResponse);
$rawBody = $rawResponse->getBody();
$httpStatusCode = …Run Code Online (Sandbox Code Playgroud) 所以我有两个表,组织和联系人。两个表都有“电子邮件”列,我需要做的是保留组织的名称,但在电子邮件列中连接所有电子邮件(组织+所有联系人电子邮件)。
这是我尝试过的一些版本,但没有成功
1)这个不分组:
$customers = DB::table('customers')
->whereRaw('LENGTH(customers.email) > 4')
->select([
'customers.id',
'customers.name',
'customers.email'
]);
$contacts = DB::table('contacts')
->whereRaw('LENGTH(contacts.email) > 4')
->leftJoin('customers', 'contacts.customer_id', '=', 'customers.id')
->select([
'customers.id',
'customers.name',
'contacts.email'
]);
return $customers
->union($contacts)
->select([
'id',
'name',
DB::raw('GROUP_CONCAT(DISTINCT email, ", ") AS emails'),
])
->groupBy('id')
->get();
Run Code Online (Sandbox Code Playgroud)
2)这个实际上非常接近,但它不会过滤掉联系人或客户整体都没有的条目DB::raw('LENGTH(email) > 4')
return $customers = DB::table('customers')
->leftJoin('contacts', 'contacts.customer_id', '=', 'customers.id')
->select([
'customers.id',
'customers.name',
'registration',
DB::raw('GROUP_CONCAT(DISTINCT contacts.email, ", ") AS contact_emails'),
'customers.email'
])
->groupBy('customers.id')
->get();
Run Code Online (Sandbox Code Playgroud)
3)我尝试更接近子查询(我知道它只会过滤掉没有电子邮件的联系人)
3.1) 尝试子查询 1 会导致错误:JoinClause::whereRaw()不存在
return $customers = …Run Code Online (Sandbox Code Playgroud) 我正在使用Guzzle 6,并且无法在客户端主体中传递带有form_params的数组
$postFields = [
form_params => [
'data[test]' => "TEST",
'data[whatever]' => "Whatever..."
]
];
$client = new GuzzleClient([
'cookies' => $jar, // The cookie
'allow_redirects' => true, // Max 5 Redirects
'base_uri' => $this->navigateUrl, // Base Uri
'headers' => $this->headers
]);
$response = $client->post('api',[$postFields]);
Run Code Online (Sandbox Code Playgroud)
最终,当我发送请求时,我的数据不见了……但是,如果我在响应中手动添加数据,它就可以正常工作。
$response = $client->post(
'api',
[form_params => [
'data[test]'=>"TEST",
'data[wht]' => 'Whatever'
],
]
// It's working this way...
Run Code Online (Sandbox Code Playgroud)
如果您需要更多信息,我希望我很清楚。提前致谢。
所以在这个应用程序中Drawing belongsTo Customer。我有数据表
<table id='drawing-table' class="table table-bordered table-hover">
<thead>
<tr>
<th>Drawing number</th>
<th>Customer</th>
</tr>
</thead>
</table>
Run Code Online (Sandbox Code Playgroud)
这表明$darwing->number和$customer->title。加载信息 I use yajra\Datatables\Datatables;.
数据是用这个 JS 方法加载的:
$(function () {
$('#drawing-table').DataTable({
processing: true,
serverSide: true,
ajax: '{{route('drawings.datatable')}}',
columns: [
{ data: 'number', name: 'number' },
{ data: 'customer.title', name: 'customer' },
]
});
});
Run Code Online (Sandbox Code Playgroud)
这个 Laravel 方法:
public function datatable()
{
$drawings = Drawing::select(array('drawings.id','drawings.number'));
return Datatables::of(Drawing::with('customer')->select('*'))->make(true);
}
Run Code Online (Sandbox Code Playgroud)
问题
$customer->title?php ×2
datatable ×1
facebook ×1
guzzle ×1
guzzle6 ×1
laravel ×1
laravel-4.2 ×1
laravel-5 ×1
laravel-5.2 ×1
mysql ×1