An open API service indexing awesome lists of open source software.

https://github.com/khaledalam/bard-sdk-php

PHP SDK/API for Google Bard (experiment version) (unofficial)
https://github.com/khaledalam/bard-sdk-php

ai bard bard-ai bard-api chatbot google sdk sdk-php

Last synced: 3 months ago
JSON representation

PHP SDK/API for Google Bard (experiment version) (unofficial)

Awesome Lists containing this project

README

          

# PHP SDK/API for Google Bard (experiment version) (unofficial)

[![Downloads](https://poser.pugx.org/khaledalam/bard-sdk-php/d/total.svg)](https://packagist.org/packages/khaledalam/bard-sdk-php)
[![Latest Stable Version](https://poser.pugx.org/khaledalam/bard-sdk-php/version.svg)](https://packagist.org/packages/khaledalam/bard-sdk-php)
[![PHP Version Require](http://poser.pugx.org/khaledalam/bard-sdk-php/require/php)](https://packagist.org/packages/khaledalam/bard-sdk-php)
[![License](https://poser.pugx.org/khaledalam/bard-sdk-php/license.svg)](https://packagist.org/packages/khaledalam/bard-sdk-php)
[![composer.lock available](https://poser.pugx.org/khaledalam/bard-sdk-php/composerlock)](https://packagist.org/packages/khaledalam/bard-sdk-php)
![workflows CI](https://github.com/khaledalam/bard-sdk-php/actions/workflows/ci.yml/badge.svg)

Reverse engineering of Google's Bard chatbot.

## Disclamer
- ApiKeyCookie.php implemented only for easing the access to Google Bard, any legal responsibilities lie with the user.
- Don't expose your `__Secure-1PSID` cookie value on the internet.

## Install
> $ composer require khaledalam/bard-sdk-php

## Test
> $ composer run test

## Auth
1. Navigate to https://bard.google.com/
2. Open "Developer Tools" from browser settings or click [F12] shortcut for console.
3. Go to Application tab => open "Cookies" from left tab => click "https://accounts.google.com" => Copy the value of `__Secure-1PSID` cookie.

## Simple Usage

Change `_YOUR_COOKIE_VALUE_`
```php
ask($question);

print_r($answer['content']);
/*
Output (May-2023):

The most recent stable version of Ubuntu LTS is Ubuntu 22.04 LTS, codenamed "Jammy Jellyfish." It was released on April 21, 2022, and will be supported with free security and maintenance updates for five years, until April 2027.

Ubuntu LTS releases are designed for use in enterprise and server environments, where reliability and stability are critical. They are also a good choice for home users who want a reliable and long-lasting operating system.
*/

} catch (Exception $e)
{
die("Error: " . $e->getMessage());
}

```

Output (May-2023):
```
The most recent stable version of Ubuntu LTS is Ubuntu 22.04 LTS, codenamed "Jammy Jellyfish." It was released on April 21, 2022, and will be supported with free security and maintenance updates for five years, until April 2027.

Ubuntu LTS releases are designed for use in enterprise and server environments, where reliability and stability are critical. They are also a good choice for home users who want a reliable and long-lasting operating system.
```

## Examples

Example1(world_datatime_ai):
> php examples/world_datetime_ai/main.php

Example2(docker)

## Technical

### Diagram

### TODOs:
- [x] Cookie
- [ ] Api key
- [ ] codecov
- [x] Testing
- [x] CI GitHub actions

### License
- [MIT](https://opensource.org/license/mit/)