I am trying to write an application that integrates with the Affiliate Window API. The only problem I have is I have literally 0 experience in php and so find myself unable to debug even the most elementary of issues.
I downloaded the below code which is supposed to be a sample application. Unfortunately running it fails at the first hurdle:
Invalid argument supplied for foreach() in /Users/ravinthambapillai/Downloads/api.client/listmerchants.php on line 9
This is the error message I get when I run the below:
Can anyone help me with what I need to fix to get this right?
<?php
define('API', 'PS');
require_once('constants.inc.php');
require_once('classes/class.ClientFactory.php');
$oClient = ClientFactory::getClient(REDACTED, REDACTED, merchant);
$listmerchants = array('iCategoryId'=> 97, 'iMaxResult' => 10);
echo 'hello world';
$oResponse= $oClient->call('getMerchantList', $listmerchants);
foreach($oResponse->oMerchant as $details){
$name = $details->sName;
$strapline = $details->sStrapline;
$description = $details->sDescription;
$logo = $details->sLogoUrl;
$showurl = $details->sDisplayUrl;
$deeplink = $details->sClickThroughUrl;
$id = $details->iId;
if ($logo<>'') {
echo "<a href=".$deeplink." title='".$name."'><img src=".$logo.
" style='float:left; margin:5px;' alt='".$name.
" :: ".$strapline." :: ".$description." :: ".$showurl.
"' width=\"88\" height=\"31\" border=\"0\"></a>";
}
}
?>
Did you update the constants in constants.inc.php?
API_USERNAME needs to be set to your account ID, and API_PASSWORD needs to be set to your Affiliate API Password as seen at https://www.affiliatewindow.com/affiliates/accountdetails.php (when you're logged in)
Related
This question already exists:
Instagram/Facebook deprecating many APIs [duplicate]
Closed 4 years ago.
After battling for many days to write a PHP script to access the feed data from selected public Facebook pages, I finally got the below code to work.
I deployed the script on my server and applied a cron to run it every hour or so for almost a month with no problems but yesterday suddenly it stopped working and now spits out the error:
Unsupported get request. Object with ID '483096775077541' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api
What has changed, could someone please help?
<?php
$config['App_ID'] = 'xxxxxxxxx';
$config['App_Secret'] = 'ssssssssssssssssssss';
$token_url = "https://graph.facebook.com/oauth/access_token?"
."client_id=".$config['App_ID']
."&client_secret=".$config['App_Secret']
."&grant_type=client_credentials";
$grant = json_decode( file_get_contents($token_url) );
$page_i = 0;
$page_target = 1;
$graph_url = "https://graph.facebook.com/483096775077541/feed?access_token=".$grant->access_token;
while ($page_i < $page_target) :
$feedtext = file_get_contents($graph_url);
$feed = json_decode( str_replace('\n','<br />',$feedtext) );
foreach($feed->data as $data)
{
if( isset($data->message) ){
$lines = explode('<br />', $data->message);
echo '
<p>
<strong>'.$lines[0].'</strong>
<div>'.$data->message.'</div>';
echo '<div>'.$data->updated_time.'</div>
<div>'.$data->id.'</div>
</p>
';
}
}
$graph_url = $feed->paging->next;
$page_i++;
endwhile;
https://developers.facebook.com/blog/post/2018/04/04/facebook-api-platform-product-changes
As we begin enhancing our new app review process and make changes to our platform, the Events, Groups, Pages and Instagram APIs will no longer be available to new developers
Since this stopped working yesterday, it is definitely related to the recent changes. The only thing you can do is wait right now.
I have been searching for days for a working example! The Netsuite documentation is really poor. I don't know what exactly are the config parameters or where I can get them.
I'm recreating the get_customer example.
My code:
<?php
require_once '../PHPToolkit/NetSuiteService.php';
$service = new NetSuiteService();
$request = new GetRequest();
$request->baseRef = new RecordRef();
$request->baseRef->internalId = "21";
$request->baseRef->type = "customer";
$getResponse = $service->get($request);
if (!$getResponse->readResponse->status->isSuccess) {
echo "GET ERROR";
} else {
$customer = $getResponse->readResponse->record;
echo "GET SUCCESS, customer:";
echo "\nCompany name: ". $customer->companyName;
echo "\nInternal Id: ". $customer->internalId;
echo "\nEmail: ". $customer->email;
}
?>
This is the thrown error:
Webservice host must be specified in NSPHPClient->__construct()
How can I fix this?
To be clear, there should be a file in the same directory as NetSuiteService.php called NSconfig.php. You don't need to include this file in your script; it gets called from NSPHPClient.php. The default NSconfig.php looks like this:
$nsendpoint = "2013_2";
$nshost = "https://webservices.netsuite.com";
$nsemail = "jDoe#netsuite.com";
$nspassword = "mySecretPwd";
$nsrole = "3";
$nsaccount = "MYACCT1";
The nsendpoint and nshost should stay as they are.
The tricky part is getting the correct settings for the other variables. First off, you need to Set up Web Services (http://www.netsuite.com/portal/partners/integration/download/SuiteTalkWebServicesPlatformGuide_2012.2.pdf Starting at page 34), then you need to create a Web Services Role (page 44), and make sure that Role has the necessary permissions. Assign that Role to a user that also has the appropriate permissions, then...
nsemail = the email of the user with the web services role
nspassword = the password of the nsemail user
nsrole = the internal role id of the web services role
nsaccount = your netsuite account number (most likely six digits)
(for info on seeing your internal role ids, see page 20 of the PDF above.)
Make sure that you have included the NSconfig.php file. Also you need to modify this file with your account credentials
Hi, I am trying to get file link after upload afile using mediafire api
$appId = "";
$apiKey = "";
$email = "";
$password = "";
include("../mflib.php");
$mflib = new mflib($appId, $apiKey);
$mflib->email = $email;
$mflib->password = $password;
$sessionToken = $mflib->userGetSessionToken();
$uploadKey = $mflib->fileUpload($sessionToken, "500px-PHP.png");
$mp3=$mflib->fileGetLinks($quickkey,'direct_download',$sessionToken);
But it gives me the following error:
Error - Get file links : "Invalid parameter 'quickkey' specified" (0)
The file is already uploaded but I can't get the link
I trying to get the $quickkey.
What is the right way to get it?
Once you completed the upload, use the key from the response (response.doupload.key) to poll the upload. it is known as the upload_key.
The whole idea is to see if the upload has truly been completed (which should produce a quickkey).
When you poll the upload (intermittently , say a couple of secs) using the upload_key,
check that the status(response.doupload.status==99) then get the quickkey (response.doupload.quickkey)
This is the quickkey you use in your getting the link
pls see links:
https://www.mediafire.com/developers/upload.php#poll_upload
https://www.mediafire.com/developers/download.php#direct_download_link
$data=$mflib->filePollUpload($sessionToken, $uploadKey);
$quickkey=$data['quickkey'];
$mp3=$mflib->fileGetLinks($quickkey,'direct_download',$sessionToken);
**You need to provide $quickkey but you didn't declare this veriable.**
I am using the PHP Toolkit (v20) with the Enterprise WSDL to access my Salesforce objects and records in my webapp.
I successfully got everything working on my localhost.
When I uploaded the script to my webhost (inmotion), the create function simply does not work. It does not show any errors or warnings (although I have set error reporting to E_ALL), but execution of the script simply stops when it encounters the create function.
However, running a query using the query function or something like getting the server timestamp works fine.
Again, it works fine on my localhost, so I dont think its a code problem, but for the life of me I cannot figure out the problem, as no errors/warnings are displayed nor exceptions thrown.
I should clarify that although in this example I am trying to insert into my custom object, I have tried to insert into a standard Account or Contact object as well and it has not made any difference.
It will be great if somebody can guide me on how I can go about trying to troubleshoot the problem.
Thanks.
Code is as follows:
<html>
<head></head>
<body>
<?php
ini_set("soap.wsdl_cache_enabled", "0");
define("USERNAME", "myusername");
define("PASSWORD", "mypassword");
define("SECURITY_TOKEN", "mysecuritytoken");
require_once ('soapclient/SforceEnterpriseClient.php');
try {
$sflink = new SforceEnterpriseClient();
$sflink->createConnection("soapclient/auv.wsdl.xml",null,array('trace'=>true));
//$sflink->createConnection("soapclient/auv.wsdl.xml");
$sflink->login(USERNAME, PASSWORD.SECURITY_TOKEN);
// Test to get the server timestamp - Works fine.
echo "Getting Timestamp<br>";
$resp = $sflink->getServerTimestamp();
print_r($resp);
echo "<br>";
// Test to query the server - Works fine.
$query = "SELECT Id, AccountId, FirstName, LastName FROM Contact WHERE Email = 'ankur#alfauv.com'";
$response = $sflink->query($query);
echo "Select result is: <br>";
print_r($response);
echo "<br>";
// Insert into UVSI Search Object (My custom object) - Does not work
$sObject = new stdclass();
$sObject->Account__c = "00190000006yxUrAAI";
$sObject->Contact__c = "00390000005ZYLcAAO";
$sObject->Application__c = "AAP";
$sObject->Flow__c = 66;
$sObject->Flow_Unit__c = "m3-hr";
$sObject->Dose__c = 33;
$sObject->UVT__c = 99;
echo "Attempting creation<br>";
$createResponse = $sflink->create(array($sObject), 'UVSI_Search__c');
echo "This line never prints.<br/>";
} catch (Exception $e) {
echo "In error condition<br>";
echo $sflink->getLastRequest();
echo $e->faultstring;
exit();
}
?>
</body>
</html>
After breaking my head over this for 3 days, I finally found a solution. I changed the PHP version for my site from 5.2 to 5.3 and the problem just went away.
I still dont know why it did not work, but this is the solution in case anybody else has a similar problem.
So i have the API documentation, i have it working as far as logging me in. When i try to send an error the class just has return true so that does not help much. The IM is not being sent so i changed the class to return why it is not being sent.
> Fetching request token > Fetching access token > Signon as: {MY_ACCOUNT}#yahoo.com > {"error":{"code":-1005,"detail":"Invalid Argument Error","description":"Invalid Argument Error"},"code":-1005}
Trying to send the IM uses
$sendIm = $engine->send_message($toAddress, 'TEST');
print_r($sendIm);
I have tried
$toAddress = 'theirAddress';
AND
$toAddress = 'TheirAddress#yahoo.com';
Looking at http://developer.yahoo.com/messenger/guide/ch02.html shows that -1005 is a "bad argument", however there are only 2 passed into the IM function, to & msg, both of which are correct. Anyone else have this issue? Anyone with any ideas?
Ok, it is now figured out for anyone else who has this issue, in the class's "send_message" function
$postdata = '{"message" : '. $message. '}';
is WRONG and needs to be
$postdata = '{"message" : "'. $message. '"}';
Notice the quotes around $message. This is all it took! Simple typo in the API.