postComment
Beschreibung
Diese Methode setzt einen Beitrag zu einem bestimmten Item (z.B. ein Youtube-Video oder eine Facebook-Benutzer-ID) auf der Providerseite ab.
Kommunikation zwischen
Consuming-Party Backend > allyve Backend
Request-URL
/api/sociallyve/protected/user/comment
Methoden-Typ
POST
Request-Parameter
| Feld | Beschreibung |
|---|---|
| provider | Der angefragte Provider als Stringkonstante. Eine Liste der unterstützten Provider finden Sie unter "Provider" |
| uid | Die ID des Nutzers beim betroffenen Provider. |
| itemid | Die ID des Items, zu dem der Kommentar abgesetzt werden soll. Bisher unterstützt: Video-ID bei Youtube und Benutzer-ID bei Facbook (Kommentar an die Pinwand des angegebenen Benutzers, ab API-Version 0.9.5) |
| t | Der Kommentartext |
| partyid | Optionaler Parameter zur Identifikation der aufrufenden Anwendung in den Statistiken |
allyve-Backendaktivität
Backend übermittelt die Parameter für den Kommentar an die Providerschnittstelle.
Response
HTTP-Status
Response-Parameter
keine
Mögliche HTTP Error Codes
| HTTP Code | Beschreibung |
|---|---|
| 400 | Ein unbekannter Fehler ist aufgetreten. |
| 404 | Der angegebene Benutzer wurde nicht gefunden. |
| 406 | Der angegebene Provider ist unbekannt oder PostComment ist für den angegebenen Provider nicht verfügbar. |
| 503 | Fehler bei Kommunikation mit dem Provider. |
Code-Beispiel: PHP
//Your application's credentials for using the API $myAppKey = '12345678910111213'; $myAppSecret = 'IWillNeverTellThisToAnyone'; //Set the correct API URL to use $apiUrl = 'https://api.allyve.com/api/sociallyve/protected/user/comment'; //construct an array with all the neccessary parameters needed for the request to the API $params["timestamp"] = time(); $params["applicationid"] = $myAppKey; $params["provider"] = 'youtube'; $params["uid"] = 'userIdAtYoutube'; $params["itemid"] = 'itemIdAtYoutube'; $params["t"] = 'The message that will be posted on the item'; //sort the parameters array alphabetically by the array keys ksort($params); //construct a temporary array, that will hold concatinated keys and values of the parameter array (key=value) $tempArray = array(); //walk over the parameter array and combine each key and value foreach ($params as $key => $value) { $tempArray[] = $key . "=" . $value; } //construct a properly formatted querystring from the combined key/values $queryStringUnsigned = implode("&", $tempArray); //construct the signature $querySignature = base64_encode(hash_hmac("sha1", $queryStringUnsigned, $myAppSecret, true)); //append the signature to the unsingend query string $queryStringSigned = $queryStringUnsigned . "&signature=" . urlencode($querySignature); //let's call the API with the help of CURL $curl = curl_init($apiUrl); curl_setopt ($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); //If you do not have alredy set up a CA cert bundle in PEM format uncomment the next line, BUT YOU SHOULD NOT DO THAT IN PRODUCTION //curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); //If you have a CA cert bundle set the path to it (http://curl.haxx.se/docs/caextract.html) $pathToMyCertBundle = getcwd().'/cacert.pem'; curl_setopt($curl, CURLOPT_CAINFO, $pathToMyCertBundle); curl_setopt($curl, CURLOPT_POSTFIELDS, $queryStringSigned); curl_exec($curl); $info = curl_getinfo($curl); curl_close($curl); if (is_array($info) && isset($info['http_code']) && $info['http_code'] == 200) { echo 'ok'; } else { echo 'error'; }
Weiterführende Informationen
Zuletzt aktualisiert am 9. März 2012 von admin - Anmelden
