Whatsapp php WHAnonymous framework fails to work - php

I have this code:
require_once dirname(__FILE__)."/Chat-API-master/src/Registration.php";
$username = '972********'; // Your number with country code, ie: 34123456789
$nickname = 'A****'; // Your nickname, it will appear in push notifications
$debug = true; // Shows debug log, this is set to false if not specified
$log = true; // Enables log file, this is set to false if not specified
$dst = '+9725******';
$code = '17****';
$password="";
//$w = new WhatsProt($username, $nickname, $debug, $log);
$r = new Registration($username, $debug);
//$r->codeRequest('sms'); // could be 'voice' too
//$result=$r->codeRequest('sms'); // could be 'voice' too
$r->codeRegister($code);
I took the library from this link:
https://github.com/WHAnonymous/Chat-API/wiki/WhatsAPI-Documentation
I applied the code execution as it is described. I receieved the SMS, then I used the register function, and I got this error.
Fatal error: Uncaught exception 'Exception' with message 'An error occurred registering the registration code from WhatsApp. Reason: missing' in C:\xampp\htdocs\WhatsUp\Chat-API-master\src\Registration.php:181 Stack trace: #0 C:\xampp\htdocs\WhatsUp\index.php(19): Registration->codeRegister('175746') #1 {main} thrown in C:\xampp\htdocs\WhatsUp\Chat-API-master\src\Registration.php on line 181
The response that I should be getting is a password (parameter that is called 'pwd'). I also used their two tools that are described in the link.
You can also use WART, you can download from here: /mgp25/WART
Or you can use this online tool: watools
The picture below shows the response that I got.
enter image description here
Why am I getting those errors. Where does this code go wrong? and if the framework doesnt work! what framework is there that works well?
I just need a simple code that sends a simple whatsapp message.

Related

Error validate an ID token in PHP - Google API

I am using the following example backend-auth Google
<?php
require_once 'Google/vendor/autoload.php';
$CLIENT_ID = "xxxxxxxxxx";
// Get $id_token via HTTPS POST.
$client = new Google_Client(['client_id' => $CLIENT_ID]); // Specify the CLIENT_ID of the app that accesses the backend
$payload = $client->verifyIdToken($id_token);
if ($payload) {
$userid = $payload['sub'];
// If request specified a G Suite domain:
//$domain = $payload['hd'];
} else {
// Invalid ID token
}
?>
I have already created the credentials, API, and OAUTH2
API_KEY: AIzaAsDfGuYn6nk9761kvnwMxns-PPeO1Ka1YsA
CLIENT_ID: 15123456862-94jrd0d2lis29lbl6dekpk0fp4otgm8r.apps.googleusercontent.com
CLIENT_SECRET: qertf3l3UfgdhjiWEREZI8xN
But it generates the following error:
Notice: Undefined variable: id_token in C:\Adsense\index.php on line 10
Fatal error: Uncaught LogicException: id_token must be passed in or set as part of setAccessToken in C:\Adsense\Google\vendor\google\apiclient\src\Client.php:784 Stack trace: #0 C:\Adsense\index.php(10): Google\Client->verifyIdToken(NULL) #1 {main} thrown in C:\Adsense\Google\vendor\google\apiclient\src\Client.php on line 784
I have searched this forum in the google documentation and in the google console panel but I cannot find a fixed token or how to create it, I cannot find references
https://oauth2.googleapis.com/tokeninfo?id_token=XXXXX
It's a bit of an old post, but for anyone like me and the OP struggling with this, it's actually quite a simple solution.
The example code has a commented out line that reads
// Get $id_token via HTTPS POST.
You actually have to write this code. Using the worked examples from Google, the JavaScript function passes the authentication token as idtoken.
$id_token = $_POST['idtoken'];
Will do the trick. You'll probably want to perform some basic error checking, for example,
if (isset($_POST['idtoken'])){
$id_token = $_POST['idtoken'];
$payload = $client->verifyIdToken($id_token);
...

Adding User to Chef via Chef Server API

I am attempting to create a user on my Chef Server through the Chef Server API. I am currently using a PHP wrapper for the API interface which can be found here.
I understand that in order to create a user using the API, you must provide the pivotal.pem file as well as the pivotal username.
Here is a snippet of my PHP code that I am using:
// ENVIRONMENT VARIABLES
// The URL for the Chef Server
$server = "mycompany.com";
// The name used when authenticating
$client = 'pivotal';
// The location of the file which contains the client key
$key = "../../../pivotal.pem";
// The version of the Chef Server API that is being used
$version = "12.0.2";
// Create a Chef object
$chef = new Chef($server, $client, $key, $version);
// API Request
$createUserRequest = array("name"=>$displayName, "display_name"=>$displayName, "email"=>$emailAddress, "password"=>$password);
$createUserRequest = json_encode($createUserRequest);
$chef->post('/users/', $createUserRequest);
Here is the reponse that I receive from the server:
Fatal error: Uncaught exception 'Exception' with message 'Invalid signature for user or client 'pivotal'' in C:\Workspace\SA_SSAF\app\plugin\CHEF\Chef PHP\src\Jenssegers\Chef\Chef.php:187
Stack trace:
#0 C:\..\..\app\plugin\CHEF\Chef PHP\src\Jenssegers\Chef\Chef.php(70): Jenssegers\Chef\Chef->api('/users/', 'POST', '{"name":"entra"...')
#1 C:\..\..\app\plugin\CHEF\controller\chefEnrollUser.php(55): Jenssegers\Chef\Chef->post('/users/', '{"name":"entra"...')
#2 {main}
thrown in C:\..\..\app\plugin\CHEF\Chef PHP\src\Jenssegers\Chef\Chef.php on line 187
If I try and perform a GET request using the same configuration, I receive a successful response.
Any clues as to why something like this may be happening?
Thanks

Receive error when running basic nuSOAP tutorial

I am trying to create a website that retrieves data from a Web Service using the site API.
The 'nuSOAP' PHP library seems to be a perfect way to go about this and so I have been trying to run through a basic tutorial by Scott Nichol called 'Introduction to NuSOAP'.
Here is the code for server.php:
<?php
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the server instance
$server = new soap_server;
// Register the method to expose
$server->register('hello');
// Define the method as a PHP function
function hello($name) {
return 'Hello, ' . $name;
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
...and here is the code for the client.php:
<?php
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the client instance
$client = new soapclient('http://localhost/beehive/server.php');
// Call the SOAP method
$result = $client->call('hello', array('name' => 'John'));
// Display the result
print_r($result);
?>
I have 'XAMMP' installed and so when I call up client.php via the browser it should bring up a basic page that says 'Hello, John' but instead I get the following error message:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from '.../server.php' : Start tag expected, '<' not found in C:\xampp\htdocs\beehive\client.php:7 Stack trace: #0 C:\xampp\htdocs\beehive\client.php(7): SoapClient->SoapClient('http://...') #1 >{main} thrown in C:\xampp\htdocs\beehive\client.php on line 7
I figured I should be loading the client page rather than the server, but if I load server.php then I get the error message 'This service does not provide a Web description'.
I have followed the tutorial exactly and can't figure out why it's throwing this error; can anyone please help?
Thank you!
The error you receive makes perfect sense with your error description. The server isn't responding with the right format and therefor your client breaks.
The same error is discussed here:
nusoap simple server
You need to point the client constructor to your wsdl file...
$client = new soapclient('http://localhost/beehive/server.php');

Need help updating a google spreadsheet cell using Zend gdata with PHP. I keep getting an error with the updateCell function

I have been trying to update a cell in a google spreadsheet. I'm using ZendFramework-1.12.6 and PHP Version 5.5.9. The response I get using the code is:
ERROR: Expected response code 200, got 400 The spreadsheet at this URL could not be found. Make sure that you have the right URL and that the owner of the spreadsheet hasn't deleted it.
And if I remove the error trapping I get this message:
Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 400 Missing resource version ID' in /volume1/web/Zend/Gdata/App.php:717 Stack trace: #0 /volume1/web/Zend/Gdata/App.php(933): Zend_Gdata_App->performHttpRequest('PUT', '', Array, 'put(Object(Zend_Gdata_Spreadsheets_CellEntry), NULL, NULL, NULL, Array) #2 /volume1/web/Zend/Gdata/App/Entry.php(209): Zend_Gdata_App->updateEntry(Object(Zend_Gdata_Spreadsheets_CellEntry), NULL, NULL, Array) #3 /volume1/web/Zend/Gdata/Spreadsheets.php(307): Zend_Gdata_App_Entry->save() #4 /volume1/web/gss.php(19): Zend_Gdata_Spreadsheets->updateCell('1', '1', 'test', '1zoCs23pKzQXPtB...', 'od6') #5 {main} thrown in /volume1/web/Zend/Gdata/App.php on line 717
It seems like everything works great until I try writing the string 'test' to the spreadsheet with the updateCell call. Can anyone help?
<?php
// load Zend Gdata libraries
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_Spreadsheets');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
// set credentials for ClientLogin authentication
$user = "mygmailaccount#gmail.com";
$pass = "mypassword";
// connect to API
$service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Spreadsheets($client);
// set target spreadsheet and worksheet
$ssKey = '1zoCs23pKaQXPtB2rT5Rn6KVzJalIoR5VYBnlURJRRLs';
$wsKey = 'od6';
$service->updateCell('1', '1', 'test', $ssKey, $wsKey);
?>
After several hours of troubleshooting this same problem, I eventually figured out that this is a bug or a missing feature with the "new" Google Spreadsheets.
See the comments on this post: Updating cell in Google Spreadsheets returns error "Missing resource version ID" / "The remote server returned an error: (400) Bad Request."
Information on the "new" Google Sheets: https://support.google.com/drive/answer/3541068
On that page is a link that allows you to create a new spreadsheet using the "old" Sheets: https://g.co/oldsheets
My solution was to create a new "old" sheet. I'm now able to use updateCell with no problems!
I just found your question and with some additional information I found a really easy solution so I thought I'd share that too.
The problem seems to be, that there needs to be an Etag set for the skript to perform correctly. This Etag is
array('If-Match'=> '*')
To add this as a header to every UpdateCell request go into the source file in the library path:
library/Zend/Gdata/Spreadsheets.php
and change the UpdateCell method definition from
$entry = $this->getCellEntry($query);
$entry->setCell(new Zend_Gdata_Spreadsheets_Extension_Cell(null, $row, $col, $inputValue));
$response = $entry->save();
to
$entry = $this->getCellEntry($query);
$entry->setCell(new Zend_Gdata_Spreadsheets_Extension_Cell(null, $row, $col, $inputValue));
$response = $entry->save(null,null,array('If-Match'=> '*'));
Requests are now working for me as previously.

Public stream to facebook's user wall with php?

I build a facebook app with php api, everything work fine just have a problem when i need public a message on user's Wall.
my code bellow
$appapikey = "xxxxxx";
$appsecret = "xxxxxx";
$facebook = new Facebook($appapikey, $appsecret);
$fb_user = $facebook->require_login();
if (!$facebook->api_client->users_hasAppPermission("publish_stream, status_update")){
echo '<fb:prompt-permission perms="publish_stream, status_update">Click here to grant permissions to update your status and publish to your stream.</fb:prompt-permission>';
try {
$facebook->api_client->stream_publish($message);
} catch (Exception $e) {
echo "Public error".$e->getMessage();
}
}
I had allow Permission for publish_stream but still get error
Uncaught exception 'FacebookRestClientException' with message 'Unauthorized source IP address (ip was: 69.89.31.xxx)'
Stack trace:
#0 /home/flexvnne/public_html/facebook/facebook/client/facebookapi_php5_restlib.php(345): FacebookRestClient->call_method('facebook.users....', Array)
#1 /home/flexvnne/public_html/facebook/index.php(36): FacebookRestClient->users_getInfo('625757897', 'username')
#2 {main}
thrown in /home/flexvnne/public_html/facebook/facebook/client/facebookapi_php5_restlib.php on line 1314
[16-Oct-2009 01:30:53] PHP Fatal error: Uncaught exception 'FacebookRestClientException' with message 'Unauthorized source IP address (ip was: 69.89.31.xxx)' in /home/flexvnne/public_html/facebook/facebook/client/facebookapi_php5_restlib.php:1314
Anyone known way to solved that problem ?
It looks like your users_getInfo() call is the one that is failing here, not stream publishing.
My guess is check your whitelist/blacklist in your facebook developer application app settings -- your IP might be restricted.

Categories