Skip to content

Official PHP client to interact with MySocialApp API - Create your own social network app

Notifications You must be signed in to change notification settings

MySocialApp/mysocialapp-php-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 

Repository files navigation

mysocialapp-php-client

MySocialApp - Seamless Social Networking features for your app

Official PHP client to interact with apps made with MySocialApp

What is MySocialApp?

MySocialApp’s powerful API lets you quickly and seamlessly implement social networking features within your websites, mobile and back-end applications. Our API powers billions of requests for hundred of apps every month, delivering responses in under 100ms.

What can you do?

Add social features to your existing app, automate actions, scrape contents, analyze the users content, add bot to your app, almost anything that a modern social network can bring.. There is no limit! Any suggestion to add here? Do a PR.

What features are available?

Feature Server side API Swift client API
Profile management ✔️ ✔️
Feed ✔️ Partially
Comment ✔️ Soon
Like ✔️ Soon
Notification ✔️ Partially
Private messaging ✔️ Soon
Photo ✔️ Soon
User ✔️ ✔️
Friend ✔️ ✔️
URL rewrite ✔️ ✔️
URL preview ✔️ ✔️
User mention ✔️ ✔️
Hash tag ✔️ ✔️
Search users ✔️ Soon
Search news feed ✔️ Soon
Search groups ✔️ Soon
Search events ✔️ Soon
Group [optional module] ✔️ Soon
Event [optional module] ✔️ Soon
Roadbook [optional module] ✔️ Soon
Live tracking with RideShare (exemple here) [optional module] ✔️ Soon
Point of interest [optional module] ✔️ Soon
Admin operations ✔️ Soon

Looking for official TypeScript / JavaScript client API ? Click here Looking for official Java/Kotlin client API ? Click here Looking for official Swift client API ? Click here

Coming soon:

  • Real time downstream handlers with FCM (Android), APNS (iOS) and Web Socket.

Prerequisites

You must have "APP ID" to target the right App. Want to create your app?

App owner/administrator:

Sign in to go.mysocialapp.io and go to API section. Your APP ID is part of the endpoint URL provided to your app. Which is something like https://u123456789123a123456-api.mysocialapp.io. Your APP ID is u123456789123a123456

App user:

Ask for an administrator to give you the APP ID.

Usage

To use the SDK, you must use any of the currently available autoload (cf. autoload).

Here is an example of this SDK usage. Much more examples are coming very soon.

<?php
// Example of autoload script
spl_autoload_register(function ($class) {
    $c = explode("\\", $class);
    if (count($c) == 0 || strlen($c[0]) > 0) {
        while (count($c) > 0) {
            if (file_exists(__DIR__ . "/" . implode("/", $c) . ".php")) {
                require_once __DIR__ . "/" . implode("/", $c) . ".php";
                break;
            }
            if (count($c) == 1 && file_exists($c[0] . ".php")) {
                require_once $c[0] . ".php";
                break;
            }
            array_pop($c);
        }
    }
});

// First, create the main instance to access the API
$msa = (new \MySocialApp\MySocialAppBuilder())
    // Set the app id matching your application. Here is the test application
    ->setAppId("u470584465854a728453")
    // If you want to debug the API calls, add the following part
    // ->setClientConfiguration(new \MySocialApp\Services\ClientConfiguration(10000,10000, array(), true))
    ->build();

// Create a new user account
$session = $msa->createAccount("myusername", "myemail@mydomain.com", "mypassword", "my first name");
// If the account is already created, replace the line above with this one below
// $session = $msa->connectByEmail("myemail@mydomain.com", "mypassword");

if ($session instanceof \MySocialApp\Models\Error) {
    // Something went wrong, let's display the error
    echo $session;
} else {
    // Set the user external id to match another system's id
    $myAccount = $session->getAccount()->get();
    $myAccount->setExternalId("My external id, can be any string");
    $myAccount->save();

    // Add another user as a friend
    $anotherUser = $session->getUser()->getByExternalId("Another external id");
    $anotherUser->requestAsFriend();

    // Post a new message on the wall
    $myAccount->sendWallPost(
        (new \MySocialApp\Models\FeedPostBuilder())
            ->setMessage("My new message on the wall")
            ->setVisibility(\MySocialApp\Models\AccessControl::_PUBLIC)
            ->build()
    );

    // Once everything is done, disconnect
    $session->disconnect();
}

Demo apps using MySocialApp

Contributions

All contributions are welcomed. Thank you

About

Official PHP client to interact with MySocialApp API - Create your own social network app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages