Coder Social home page Coder Social logo

constantcontact's Introduction

PHPFUI Tests Latest Packagist release

PHP Wrapper for the Foundation CSS Framework

PHPFUI, PHP Foundation User Interface, is a modern PHP library that produces HTML formated for Foundation. It does everything you need for a fully functional Foundation page, with the power of an OO language. It currently uses Foundation 6.6.

"I was surprised that people were prepared to write HTML. In my initial requirements for this thing, I had assumed, as an absolute pre-condition, that nobody would have to do HTML or deal with URLs. If you use the original World Wide Web program, you never see a URL or have to deal with HTML. You're presented with the raw information. You then input more information. So you are linking information to information--like using a word processor. That was a surprise to me--that people were prepared to painstakingly write HTML."

Sir Tim Berners-Lee, inventor of the World Wide Web

Using PHPFUI for view output will produce 100% valid HTML and insulate you from future changes to Foundation, your custom HMTL layouts, CSS and JS library changes. You write to an abstract concept (I want a checkbox here), and the library will output a checkbox formatted for Foundation. You can inherit from CheckBox and add your own take on a checkbox, and when the graphic designer decides they have the most awesome checkbox ever, you simply change your CheckBox class, and it is changed on every page system wide.

Don't write HTML by hand!

Usage

namespace PHPFUI;
$page = new Page();
$form = new Form($page);
$fieldset = new FieldSet('A basic input form');
$time = new Input\Time($page, 'time', 'Enter A Time in 15 minute increments');
$time->setRequired();
$date = new Input\Date($page, 'date', 'Pick A Date');
$fieldset->add(new MultiColumn($time, $date));
$fieldset->add(new Input\TextArea('text', 'Enter some text'));
$fieldset->add(new Submit());
$form->add($fieldset);
$page->add($form);
$page->addStyleSheet('/css/styles.css');
echo $page;

Installation Instructions

composer require phpfui/phpfui

Then run update.php from the vendor/phpfui/phpfui directory and supply the path to your public directory / the directory for the various JS and CSS files PHPFUI uses. This will copy all required public files into your public directory. For example:

php vendor/phpfui/phpfui/update.php public/PHPFUI

The PHPFUI library defaults to your-public-directory/PHPFUI, it can be overridden, but it is suggested to use PHPFUI to keep everything in one place. update.php should be run when ever you update PHPFUI.

Versioning

Versioning will match the Foundation versions for Major semantic versions. PHPUI will always support the most recent version of Foundation possible for the Major version. PHPFUI Minor version will include breaking changes and may incorporate changes for the latest version of Foundation. The PHPFUI Patch version will include non breaking changes or additions. So PHPFUI Version 6.0.0 would be the first version of the library, 6.0.1 would be the first patch of PHPFUI. Both should work with any Foundation 6.x version. PHPFUI 6.1.0 will track PHP 7.4 - 8.1, 6.2.0 will track 8.0 - 8.2, but both will still track Foundation 6.x. PHPFUI 7.0.0 would track Foundation 7.x series on currently supported versions of PHP.

Depreciation and Foundation changes

Since major versions of Foundation have in the past depreciated and obsoleted things, PHPFUI will track the latest version of Foundation for class names and functionality. However, when Foundation makes a breaking change or removes something, PHPFUI will continue to support the old functionality as best as possible in the new Foundation framework. Depreciated classes will be put in the \PHPFUI\Vx namespace (where x would be the prior Major Foundation version containing that feature). So if something gets depreciated in a newer version of Foundation, you simply will need to change your code from \PHPFUI\Example to \PHPFUI\V6\Example. The depreciated namespace will only be supported for one Major version of PHPFUI, so it is recommended you migrate off of it in a timely manor.

Full Class Documentation

PHPFUI/InstaDoc

Live Examples

Via PHPFUI/Examples

Unit Testing

Full unit testing using phpfui/html-unit-tester

License

PHPFUI is distributed under the MIT License.

PHP Versions

This library only supports modern versions of PHP which still receive security updates. While we would love to support PHP from the late Ming Dynasty, the advantages of modern PHP versions far out weigh quaint notions of backward compatibility. Time to upgrade.

constantcontact's People

Contributors

phpfui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

constantcontact's Issues

Session handler and samesite cookies.

Hello,

Appreciate your hard work on this library.

Do you have any suggestion on how this can be used with Samesite cookies set as Strict?

I found that in our Session implementation with Laravel, when cookies are stored as LAX it will Authorize fine, however when Samesite Cookies are set as Strict, I get an Unauthorized response back. I assume because of the offsite transfer the session is lost.

Is there any other suggestion on how to still use this Library with Samesite cookies set as strict or an alternative way of handling this from within the session handler?

Again, your work and time on this is greatly appreciated, hoping some simple way around this.

Empty tokens returned

I think I do everything right, the verification returns to my redirect URI, with values in the 'code' and 'state' _GET vars. But the getAuthorizationURL() function does not seem to update the $client class with accessToken and refreshToken, or Constant Contact does not return them or returns empty values. In any case, accessToken and refreshToken are empty. No errors are reported either.

I am on PHP 8.1.21.

Please help.

Custom fields exist but are not populated on JsonImportContact

I have created custom fields on the authorised account but they are not populated.
There are no errors. I get 'initialized' state on response, the contacts are created with all predefined fields but no custom fields are populated.
Any ideas?

My code looks like this:

            $import_data = array();
            foreach ($args['contacts'] as $contact) {
                if ($contact["status"] == "subscribed") {
                    $item = array(
                        "email" => $contact['email_address'],
                        "first_name" => $contact['merge_fields']['FNAME'],
                        "last_name" => $contact['merge_fields']['LNAME'],
                        "birthday_month" => \intval(\substr($contact['merge_fields']['BIRTHDAY'], 3, 2)),
                        "birthday_day" =>  \intval(\substr($contact['merge_fields']['BIRTHDAY'], 0, 2)),
                        "country" => $contact['merge_fields']['COUNTRY'],
                        "cf:gender" => $contact['merge_fields']['GENDER'],
                        "cf:nps_score" => (string) $contact['merge_fields']['NPS'],
                        "cf:language" => $contact['merge_fields']['LANGUAGE']
                    );
                    $import_data[] = new \PHPFUI\ConstantContact\Definition\JsonImportContact($item);
                }
            }
            $list_ids = array(new \PHPFUI\ConstantContact\UUID($args['listid']));
            $client->accessToken = $args['accessToken'];
            $client->refreshToken = $args['refreshToken'];
            $ContactsJsonImportDefinition = new \PHPFUI\ConstantContact\Definition\ContactsJsonImport(array('import_data' => $import_data, 'list_ids' => $list_ids));
            $contactsJsonImport = new \PHPFUI\ConstantContact\V3\Activities\ContactsJsonImport($client);
            return [
                'result' => $contactsJsonImport->post($ContactsJsonImportDefinition)
            ];

Using API without authorization process

I'm trying to use the API for a simple email signup form on a website. I need to get the access and refresh tokens, but in this use case there are no user redirect URLs or anything like that. What is the process for adding a contact without redirecting?

Token vars blank after calling RefreshToken

I set the $client->accessToken & client->$refreshToken vars then do a refreshTocken() and the $client->accessToken & $client->refreshToken are blank after that?

Any Idea why?

List of Campaigns

With the ConstantContact API you can get a list of Campaigns by calling the V3\Emails but when I look at your docs, I only see V3\Email\Activities, so how do I get a list of Campaigns with yours?

Examples on how to add a contact

Do you have example code on how to add a contact by any chance?

I see that you have to create a PHPFUI\ConstantContact\Definition\ContactPostRequest first and then do a \PHPFUI\ConstantContact\V3\Contacts.

Your help is very much appreciated.

Thank you.

Michel

Client::session() Return value must be of type string, null returned

Hi there,

I am using this awesome library here to add Constant Contact API integration with Contao. I am having this error setting up the initial connection. The crazy thing is, it works as expected and it does establish my connection, it just happens that Contao crashes at the same time. I have seen this error a lot recently and I think it might have something to do with PHP 8.1. This is the error I am getting:

[2022-12-06T19:35:16.951748+00:00] request.CRITICAL: Uncaught PHP Exception TypeError: "PHPFUI\ConstantContact\Client::session(): Return value must be of type string, null returned" at /home/framework/public_html/vendor/phpfui/constantcontact/src/ConstantContact/Client.php line 500 {"exception":"[object] (TypeError(code: 0): PHPFUI\\ConstantContact\\Client::session(): Return value must be of type string, null returned at /home/framework/public_html/vendor/phpfui/constantcontact/src/ConstantContact/Client.php:500)"} []

Request for PHP 7.4 support.

Constant Contact requires us to upgrade the API to V3 before Aug/2022. Currently, our system is using PHP7.4, we can not wait for upgrading the PHP version from 7.4 to 8.0, Thus could you please create a version that supports PHP7.4???

invalid_grant: The refresh token is invalid or expired.

Hi,

I'm using using server flow to get the access token and refresh token,

I saved both access token and refresh token.

When i call the refreshToken method, i get this error: invalid_grant: The refresh token is invalid or expired..

What should i do so the refresh token is not expired or get updated?

Thnkas

Contact Delete Returns an error

Sorry to bother you again, but I have an issue using the contact delete, here is the code:
$contact_id="f30421a0-cbc8-11ec-a48c-fa163e3c5d75";
$contact= new \PHPFUI\ConstantContact\V3\Contact($client);
$contact->delete($contact_id);

And here is the error returned:
Fatal error: Uncaught TypeError: PHPFUI\ConstantContact\Base::doDelete(): Return value must be of type array, bool returned in /home4/rpatorg/public_html/includes/ConstantContact/src/ConstantContact/Base.php:47 Stack trace: #0 /home4/rpatorg/public_html/includes/ConstantContact/src/ConstantContact/V3/Contact.php(80): PHPFUI\ConstantContact\Base->doDelete(Array) #1 /home4/rpatorg/public_html/includes/cc_api.php(90): PHPFUI\ConstantContact\V3\Contact->delete('f30421a0-cbc8-1...') #2 /home4/rpatorg/public_html/admin/cron_cc.php(14): CCRemoveContact('f30421a0-cbc8-1...') #3 {main} thrown in /home4/rpatorg/public_html/includes/ConstantContact/src/ConstantContact/Base.php on line 47

Line 80 in contact.php is:
return $this->doDelete(['contact_id' => $contact_id, ]);

Thank you for your help.

Michel.

Get all contacts that have pagination

Hi,

first of all thanks a lot for the library.

I'm trying to get all contacts by using this code. I have 3 contacts for testing purpose.
`$contactsResponse = $contactsEndPoint->get('all',null,$list_id,null,null,null,null,null,null,null,null,null,null,true,1);

    do {
        $contactsResponse = $contactsEndPoint->next();
        print_r(contactsResponse);
    } while ($contactsResponse);`

I'm getting 504 document error and i'm only get the first and the second contact but no on the third contact.

What is the correct way to use the next()?

Thanks a lot.

ContactList returns nothing

I followed your example, but when I do $listEndPoint = new \PHPFUI\ConstantContact\V3\ContactLists($client);

Nothing is returned, yet I have lots of lists.

Any idea why?

Thank you.

Michel

http_build_param Issue

When tryin to authenticate, the authentication url uses & instead of just &.
Tried both approach and the url with just "&" is the one working.. & returns 400 error.

After some tests, seems that it only happens when using the php head redirect (\header('location: ' . $client->getAuthorizationURL());)

Im not sure if this is related to that but when getting the access_toke, I don't get results. I have the code and state in url but still no access_token or refresh token after calling $client->acquireAccessToken($_GET);
object(PHPFUI\ConstantContact\Client)#22 (17) { ["accessToken"]=> string(0) "" ["refreshToken"]=> string(0) "" ["authorizeURL":"PHPFUI\ConstantContact\Client":private]=> string(61) "https://authz.constantcontact.com/oauth2/default/v1/authorize"

How to use setSessionCallback?

Thanks for this library, your time is greatly appreciated!

Any example on how to use the setSessionCallback? I was testing this with Laravel real quick, but I am unable to get $client->accessToken or $client->refreshToken to output. If I switch to using PHP's start_session() it works, but the application I want to implement into uses its own session handler.

I assume I am doing the callback incorrect or missing something?

$client = new Client($apiKey, $secret, $redirectURI);

$client->setSessionCallback(function ($key, $value) use ($request) {
    $request->session()->put($key, $value);
    return $request->session()->get($key) ?? '';
});

$client->acquireAccessToken($_GET);

echo $client->accessToken . '<br>';
echo $client->refreshToken . '<br>';

dd($request->session()->all());`

New endpoints, current ones expiring March 31

Hey there! I am not familiar with the automated update.php solution in order to make a PR. Was given a heads up from CC a day or two ago about new API endpoints for all new developer 'apps'. And that current developer apps will expire on March 31, 2022.

This application sends GET requests to https://authz.constantcontact.com/oauth2/default/v1/authorize to initiate authorization requests.

This application sends POST requests to https://authz.constantcontact.com/oauth2/default/v1/token to exchange authorization codes for bearer tokens.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.